SAS Programming

DATA Step, Macro, Functions and more
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
SAS Super FREQ

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
SAS Super FREQ

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

 

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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