I am new to proc report. Using across to nest two variables together. However, all the results are not on the same row and are scattered
This is what I have:
THis is my code and sample data structure
Data have; retain IGA group Week1 Week2 CatC CatN;; length CatC $ 10.; input IGA group Week1 Week2 CatC $ CatN; cards; 1 3 . . N 1 1 3 . . Mean 2 2 3 1 1 N 1 2 3 2.3 2.0 Mean 2 3 3 3 3 N 1 3 3 1.9 2.0 Mean 2 4 3 3 3 N 1 4 3 0.9 1.3 Mean 2 5 3 4 4 N 1 5 3 1.7 1.3 Mean 2 ; ods tagsets.rtf file="&path.\output\Draft\&pgm..rtf" style=rtfdef startpage=yes nogtitle nogfootnote; proc report data=have nowindows headline headskip SPANROWS split='|' spacing=4 style(header)={ just=center asis=on} style(column)={asis=on} style(report)={width=9 in}; column group CatN CatC (IGA, (Week1 Week2)); define IGA/across order=data style(header)=[just=center fontweight=bold asis=on] style(column)=[just=center asis=on]; define group/order=data group "Age Group" style(header)=[just=left fontweight=bold asis=on] style(column)=[just=left asis=on cellwidth=0.7in]; define CatN/order=data noprint; define CatC /display 'Statistic' style(header)=[just=center fontweight=bold asis=on] style(column)=[just=left asis=on cellwidth=0.7in]; define Week1/display style(header)=[just=center fontweight=bold asis=on] style(column)=[just=center asis=on cellwidth=0.7in ]; define Week2/display style(header)=[just=center fontweight=bold asis=on] style(column)=[just=center asis=on cellwidth=0.7in ]; run; ods tagsets.rtf close;
How do I get all N and mean to report on the same row across the IGA variable and weeks?
I found this article https://www.lexjansen.com/pharmasug/2012/TF/PharmaSUG-2012-TF20-SAS.pdf
I've tried the dummy variable method and that did not work.
Your data structure is not the same as in the article, where they use a single variable for gender (not separate M and F).
To use the code in the paper, I would suggest you reorganize your data in a longitudinal timeseries format, with a single variable representing week number.
This will also give you the flexibility to add additional weeks when needed.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.