BookmarkSubscribeRSS Feed
andreas_lds
Jade | Level 19

I would use RWI to create a report with so many special layout requirements.

Oligolas
Barite | Level 11
data have;
input strain $ day cyto $ age $;
datalines;
wuhan 1 CD107a 18
wuhan 1 IFN? 18
wuhan 1 TNFa 18
wuhan 1 L-12 18
wuhan 1 CD107a 40
wuhan 1 IFN? 40
wuhan 1 TNFa 40
wuhan 1 L-12 40
wuhan 64 CD107a 18
wuhan 64 IFN? 18
wuhan 64 TNFa 18
wuhan 64 L-12 18
wuhan 64 CD107a 40
wuhan 64 IFN? 40 
wuhan 64 TNFa 40
wuhan 64 L-12 40
wuhan 120 CD107a 18
wuhan 120 IFN? 18
wuhan 120 TNFa 18
wuhan 120 L-12 18
wuhan 120 CD107a 40
wuhan 120 IFN? 40
wuhan 120 TNFa 40
wuhan 120 L-12 40
wuhan 360 CD107a 18
wuhan 360 IFN? 18
wuhan 360 TNFa 18
wuhan 360 L-12 18
wuhan 360 CD107a 40
wuhan 360 IFN? 40
wuhan 360 TNFa 40
wuhan 360 L-12 40
;
run;
data want;
set have;
if age= "18" then agegrp = "18-39";
else if age = "40" then agegrp = "40-60";
drop age;
run;

proc sort data=want out=want1;by strain day agegrp; run;

data want2;
   set want1;
   by strain day agegrp;
   retain agegrpcat .;
   if first.agegrp then agegrpcat+1;
run;

data want3;
   set want2(rename=(day=_day));
   by strain _day agegrp agegrpcat;
   output;

   if last.agegrpcat then do;

      ARRAY chars _CHARACTER_;
      do over chars;
         if strip(upcase(vname(chars))) not in ('STRAIN' 'AGEGRPCAT' '_DAY') then do;
            call missing(chars);
         end;
      end;

      ARRAY nums _NUMERIC_;
      do over nums;
         if strip(upcase(vname(nums))) not in ('STRAIN' 'AGEGRPCAT'  '_DAY') then do;
            call missing(nums);
         end;
      end;
      day=_day;
      output;
   end;
   drop _day;
run;

ods pdf file="C:\Users\Classroom\Desktop\internship\practice.pdf";
proc report data=want3 spanrows headskip nowd headline ps=170 split='*' missing contents="";
   column strain day agegrp agegrpcat Cyto;
    define strain    / style={just=c asis=on cellwidth=6% vjust=center} order            flow;
    define day       / style={just=c asis=on cellwidth=7% vjust=center} "Day"       flow;
    define agegrp    / style={just=c asis=on cellwidth=9% vjust=center} "Age Group" flow;
    define agegrpcat / noprint ;
    define Cyto      / style={just=c asis=on cellwidth=7%} "Cytokine" display flow;
run;
ods pdf close;
________________________

- Cheers -

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 16 replies
  • 2133 views
  • 0 likes
  • 6 in conversation