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

Hello,

 

I am generating a report using proc report and need the column header to print either A Period   or B Period based on the value of the variable trtn in my dataset. An if/else statement does not work.  Can anyone provide a suggestion?

 

thank you

KC

Kc2_1-1668093080382.png

proc report data=final style=[outputwidth=100%];
columns trtn ord ("__Period A______________________________________________________________________________________________________"
c1 ("______________________________CTCAE Grade______________________________" c3 c4 c5 c6 c7));
/* if trtn=3 then columns trtn ord ("__Period B___________________________________________________________________________________________________" */
/* c1 ("______________________________CTCAE Grade______________________________" c3 c4 c5 c6 c7)); */

define trtn /order noprint order=internal;
define ord /order noprint order=internal;
define c1 /group display "System Organ Class/^ Preferred Term [1]" style(column)=[cellwidth=20% just=LEFT asis=on] style(header)=[just=l];

define c3 / "Grade 1/^[Events] (%)" style(column)=[cellwidth=11% just=c] flow;
define c4 / "Grade 2/^[Events] (%)" style(column)=[cellwidth=11% just=c] flow;
define c5 / "Grade 3/^[Events] (%)" style(column)=[cellwidth=11% just=c] flow;
define c6 / "Grade 4/^[Events] (%)" style(column)=[cellwidth=11% just=c] flow;
define c7 / "Grade 5/^[Events] (%)" style(column)=[cellwidth=11% just=c] flow;


break after trtn / page;
compute after ord;
line ' ';
endcomp;
run;

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
Diamond | Level 26

Hi:

  Unless you used BY group processing so you could create a report for every value of TRTN, I think you might need a SAS Macro program, something like this:

Cynthia_sas_0-1668096835270.png

  This is not the exact format as your output, since it uses SASHELP.CLASS for the example, but it illustrates the general concept. There are other ways to write the macro program, of course, but I based this on an example I already had available.

Cynthia

 

View solution in original post

1 REPLY 1
Cynthia_sas
Diamond | Level 26

Hi:

  Unless you used BY group processing so you could create a report for every value of TRTN, I think you might need a SAS Macro program, something like this:

Cynthia_sas_0-1668096835270.png

  This is not the exact format as your output, since it uses SASHELP.CLASS for the example, but it illustrates the general concept. There are other ways to write the macro program, of course, but I based this on an example I already had available.

Cynthia

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 1 reply
  • 1042 views
  • 0 likes
  • 2 in conversation