BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Tpham
Quartz | Level 8

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:

Tpham_0-1593190652005.png

 

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Tpham
Quartz | Level 8
Closing this as I figured it out. The had to change week variable from display to analysis

View solution in original post

3 REPLIES 3
Tpham
Quartz | Level 8

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.

Tpham
Quartz | Level 8
Closing this as I figured it out. The had to change week variable from display to analysis
ghosh
Barite | Level 11

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.

CFC_SAS_Communities_400x225.jpg

Call for content now open!

It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.

Submit your proposal →

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 2591 views
  • 0 likes
  • 2 in conversation