SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
monday89
Fluorite | Level 6

I have the following table and I would like to merge and center the group by treatment groups

 

groupcategoryvalue
treatment156
treatment254
treament332
placebo145
placebo234
placebo323

 

Like this: 

dfdf.PNG

 

I tried:

 


proc report data=test nowindows split='~' spanrows
style(report)={font_size=9pt }
style(header)={just=center font_weight=bold font_size=9pt background=CXE0E0E0}
style(column)={font_size=9pt protectspecialchars=on};
column group category value;

run;

 

not sure what i am doing wrong

3 REPLIES 3
Reeza
Super User
Specify the variable as GROUP variable on the define statement and you can apply styling on the DEFINE statement for a specific variable as well.
monday89
Fluorite | Level 6

great thank you it works!

 

But now i have another issue. Currently I have only 2 groups: treatment and placebo, but if I add the third arm to be arm_3. I don’t want the order to change desc or ascending. It should be treatment, placebo, arm_3. If I add /group in the define, it doesn’t retain the order

 

Group

value

Treatment

112

Treatment

312

Treatment

423

Placebo

242

Placebo

343

Arm_3

324

Arm_3

324

I wrote the following:

proc report data=test   nowindows headline headskip;

      column group value;

      define group/ group "Treatment Group" width =14;

      define value/ group "value" width =14;

run;

 

I am getting this [I do not want to change the order of group]

Group

value

Arm_3

324

 

324

Placebo

242

 

343

Treatment

112

 

312

 

423

 

 

Reeza
Super User
Specify order=data assuming your order is specified. Otherwise your best bet is to recode them to numbers that will sort the way you want and apply a format to have the display labels you need.

sas-innovate-wordmark-2025-midnight.png

Register Today!

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.


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.

SAS Training: Just a Click Away

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

Browse our catalog!

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