I'm fairly new to SAS and I'd like to really get into returning data sets in the most efficient and economical fashion. My lack of on the job experience leads me to the following. If a client requested the have the following metrics for mean, count and sum by dpt (department), what would be the best approach to take? data sample1; infile datalines dlm=","; length fn $ 12; input fn $ dpt $ salary; datalines; john doe, fin, 50000 jane doe, fin, 69393 kim smith, it, 93893 ken smith, it, 80493 ; run; quit; something as simple as: proc means data=sample1 sum n mean; class dpt; run; quit; or would we write PROC SQL statement or even a data set process where we're grouping to get our totals. The Proc Means approach is really quick but it doesn't push the boundaries of being a good programmer. With an approach like data mt_samp (drop=fn); set sample1 ; by dpt; if First.dpt then total = 0; if First.dpt then cnt = 0; if First.dpt then ave = total /cnt; /** this line doesn't work, sorry total+salary; cnt+1; if Last.dpt then output; run; quit; Thanks, SJ
... View more