BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
RandoDando
Pyrite | Level 9

I am trying to insert lines of text after 3 specific rows in my report in PROC REPORT.  I have a field called ROW which is called in the column statement and not printed in the report.  I want a line of text after row 5, row 12, and row 33.   I tried this below and get a row after each row between 5 and 12, 12 and 33, etc...  

 

compute after row;
 	if row =5 then do;
   text='Group A'; len=50;
  end;

	if row =12 then do;
   text='Group B'; len=50;
  end;

  	if row =33  then do;
   text='Group C'; len=50;
  end;
  line text $50.  ;
   endcomp; 
1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hi @RandoDando,

 

According to Sample 37763: Conditionally print a LINE statement in PROC REPORT you should use the $VARYINGw. format and define len=0 for the remaining rows:

compute after row;
  len=50;
       if row= 5 then text='Group A';
  else if row=12 then text='Group B';
  else if row=33 then text='Group C';
  else len=0;
  line text $varying. len;
endcomp;

View solution in original post

2 REPLIES 2
FreelanceReinh
Jade | Level 19

Hi @RandoDando,

 

According to Sample 37763: Conditionally print a LINE statement in PROC REPORT you should use the $VARYINGw. format and define len=0 for the remaining rows:

compute after row;
  len=50;
       if row= 5 then text='Group A';
  else if row=12 then text='Group B';
  else if row=33 then text='Group C';
  else len=0;
  line text $varying. len;
endcomp;
RandoDando
Pyrite | Level 9

I actually tried using the $varying statement but it produced really cryptic, "unknown" errors in SAS, so I changed it back to 50. . I'll try it exactly the way you entered it and see...

 

EDIT: Tried it as entered above and it worked.  Thanks

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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
  • 2 replies
  • 1406 views
  • 0 likes
  • 2 in conversation