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;
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;
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;
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
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.