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

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