Hi, I am new to R.
I am trying to create an R function to do a SAS proc means/summary proc.means ( data=bsebal; class team year; var ab h; output out=BseBalAvg mean=; run;) I have a solution if I quote the the argument. The working code to produce BseBalAvg is very elegant. normalize <- melt(bsebal, id=c("team", "year")) # normalize data transpose <- cast(normalize, team + year ~ variable ,mean) # team year h ab (means) Here is the problem In SAS we have the option parmbuff which puts all the 'macro arguments' text into one string ie %macro procmeans(text)/parmbuff; %put &text; %mend procmeans; %procmeans(This is a sentence); result This is a sentence Here is my R code # This works proc.means <- function(....) { sapply(match.call()[-1],deparse) } proc.means(thisisasentence) Result .... "thisisasentence" Note sapply allows for multiple arguments and is not needed but is more robust. # However this does not work proc.means(this is a sentence) unexpected symbol in "proc means(this is) It appears that the second space causes the error I have had some luck using formulas # This works in spite of the spaces proc.means <- function(formula) { parmbuff <- deparse(substitute(formula)) print(parmbuff) } proc.means(team + year + variable) # this does not work - same issue as above proc.means(team year variable) unexpected symbol in "proc means(team year) -- View this message in context: http://r.789695.n4.nabble.com/SAS-Proc-summary-means-as-a-R-function-tp2286888p2286888.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.