Hello everyone!
I have this dataset in SAS :
Num | var1 | var1_ | var2 | var2_ | var3 |
A1 | A | 9 | A | 8 | 2 |
A1 | B | 1 | A | 8 | 2 |
A1 | C | 1 | A | 8 | 2 |
A2 | A | 25 | A | 22 | 1 |
A2 | B | 16 | B | 13 | 1 |
A2 | C | 17 | C | 7 | 1 |
A2 | C | 17 | D | 3 | 1 |
None | A |
I want to know if there is any way to display it like this using proc report :
The idea is to merge cells of var1_ if they have the same value in var1 and Num
merge cells of var2_ if they have same value in var2 and Num
and merge cells in var3 if we have same value in Num variable.
I used the code below, but I didn't get the requested result:
proc report data=data nowindows split='~' spanrows; column Num var1 var1_ var2 var2_ var3;
define Num /order ORDER=DATA style(column)=[vjust=m just=l]missing; define var1 /display missing; define var1_ /display missing; define var2 /display missing; define var2_ /display missing ; define var3/order ORDER=DATA style(column)=[vjust=m just=l]missing; run;
Thank you in advance
The behavior you are showing comes when you use a GROUP role instead of DISPLAY.
But since the value you show for var2 of A belongs to different groups in Var1 they aren't going to merge because they are actually different groups.
If the columns must be in that order with specific cell merging that are different from cell merging to the left then proc report may not be the tool you need.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.