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

I've been trying to generate a report with the layout in the image. Each line in the column title references a column in the dataset (e.g. Reported term is the column reported_term, MedDRA Preferred Term is medra_term, and so on). Each cell content should be the concatenation of the texts referred in the title, separated by a new line character. When I generate the HTML and RTF output with PROC REPORT, the result is not the desired (see second image attached, the colored ones should be placed in a new line). My approach involved using CATX with the '0A'x hexadecimal character for newline, and the definition of a split character "#" in PROC REPORT, but none of those give me a good result. If anyone could provide me a little help, I would appreciate it.

 

Image 1.

listing-example-layout.png

Image 2. RTF output from PROC Report

listing-output-rtf.png

/* Building final dataset for before reporting */
DATA ae_test_final;
  SET ae_test_2;
  /* First column */
  length subj_seqno  $50;
  length reportmdra  $150;
  length startendt   $50;
  
  /* Subject \n Seqno */
  subj_seqno = catx('0A'x, strip(subject_id), strip(put(ae_count, 3.)));
  
  /* Reported Term \n MedDRA Preferred Term \n MedDRA System Organ Class*/
  reportmdra = catx('0A'x,
                    strip(reported_term),
                    strip(meddra_prefer),
                    strip(meddra_sorgan));
                 
  /* Start Date+time/number days \n End Date+time/number days */
  if missing(enddate_2) then
  
     startendt = put(startdate_2, YYMMDD10.) || " " || starthour_ae || " / " ||
                 strip(put(ndays_start, 6.)) || "#" ||
                 "Ongoing / -";
  
  else
     startendt = put(startdate_2, YYMMDD10.) || " " || starthour_ae ||
                        " / " || strip(put(ndays_start, 6.)) || "#" ||
                      put(enddate_2, YYMMDD10.) || " " || endhour_ae || " / " ||
                      strip(put(ndays_end, 6.));
                      
RUN;


options orientation=landscape;
ods rtf file="/~/listing.rtf";
ods escapechar="^";
PROC REPORT data=ae_test_final 
            nowd headline headskip split="#" missing;
  column subj_seqno reportmdra startendt;
  
  define subj_seqno / "Subject # Seqno" order;
  define reportmdra / "Reported Term # MedDRA Preferred Term #
                       MedDRA System Organ Class" left flow;
  define startendt  / "Start Date + time / number days #
                       End Date + time / number days" left flow;
RUN;
ods rtf close;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

See if this approach to inserting a Newline call works for you. You should have the Sashelp.Class data set to test the code with.

 

data work.class;
   set sashelp.class;
   length n_s $ 35;
   n_s = catx('^{newline}',name, sex);
run;
ods escapechar='^';
proc report data=work.class split='#';
   columns n_s;
   define n_s/ display "Name # Sex";
run;

One theng to note is the Escapechar functions do want the curly braces.

Also I suggest setting a specific variable length for your variables made with the various concatenations you are using. Some of these will default to very long lengths and may cause odd behaviors as a result.

 

You will find out that some of the "white space" characters such as leading spaces, tabs and possibly the carriage return or line feed characters will be treated differently, such as ignored, in the body of procedure output.

 

View solution in original post

2 REPLIES 2
ballardw
Super User

See if this approach to inserting a Newline call works for you. You should have the Sashelp.Class data set to test the code with.

 

data work.class;
   set sashelp.class;
   length n_s $ 35;
   n_s = catx('^{newline}',name, sex);
run;
ods escapechar='^';
proc report data=work.class split='#';
   columns n_s;
   define n_s/ display "Name # Sex";
run;

One theng to note is the Escapechar functions do want the curly braces.

Also I suggest setting a specific variable length for your variables made with the various concatenations you are using. Some of these will default to very long lengths and may cause odd behaviors as a result.

 

You will find out that some of the "white space" characters such as leading spaces, tabs and possibly the carriage return or line feed characters will be treated differently, such as ignored, in the body of procedure output.

 

CarloRock
Calcite | Level 5
Thanks!, this works pretty well.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 2 replies
  • 233 views
  • 3 likes
  • 2 in conversation