2 weeks ago
I am trying to create 3 year moving average rates from a large birth file. I have used proc summary to get the data into a format to create the rates by year
proc summary data=ptm_denom; class year; var preterm birth; output out=ptmtab sum=preterm birth; run; proc print data=ptmtab; run; data ptm_rate (drop = _type_ _freq_); set ptmtab; ptmrate = (preterm/birth)*100; run; proc print data=ptm_rate noobs; var year preterm birth ptmrate; run;
And my output looks like this:
year preterm birth ptmrate
but I can't figure out how to sum and average the data and manipulate the table so my output looks like this:
This seems like there would be an easy solution, but I can't figure one out. Any help would be great!
2 weeks ago
PROC EXPAND (if you have it in your SAS license) can provide 3 year moving averages of your data.
Since your output is vertical but the table you want is horizontal, you could transpose your output, then use ARRAYs in a data step to get three year moving averages.
But just a word to the wise ... keep your final table vertical, not horizontal, it's a much easier format for SAS to work with, and much easier for people to read.