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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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