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

Dear all,

I want to print an extra line BETWEEN  groups.

When I use COMPUTE AFTER groupx this will work BUT the line will also be printed at the end of the report (after the last group)!!

And that is not what I want.

I tried something like:

COMPUTE after prod_cl;            

PROD='TOTAL' ;                   

IF prod_cl='EXTERNAL2' then do;  

   line " ";                      

   line " ";                      

   line "--Not included above--" ;

end;                             

ENDCOMP;                          

but the IF is ignored and the line statement is always executed.....

any suggestions ??

Regards,

Herman

1 ACCEPTED SOLUTION

Accepted Solutions
Tim_SAS
Barite | Level 11

Yes, LINE statements are always executed even when they're within the scope of an IF or DO. LINE statement behavior is counter-intutitive (to say the least). When PROC REPORT executes a COMPUTE block, it first removes all the LINE statements, then executes the remaining code, and only then executes the LINE statements in the order they appear in the COMPUTE block. See the Restriction here.

However, this SAS note describes a clever trick that allows a LINE statement to appear to be conditionally executed.

View solution in original post

1 REPLY 1
Tim_SAS
Barite | Level 11

Yes, LINE statements are always executed even when they're within the scope of an IF or DO. LINE statement behavior is counter-intutitive (to say the least). When PROC REPORT executes a COMPUTE block, it first removes all the LINE statements, then executes the remaining code, and only then executes the LINE statements in the order they appear in the COMPUTE block. See the Restriction here.

However, this SAS note describes a clever trick that allows a LINE statement to appear to be conditionally executed.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1 reply
  • 762 views
  • 0 likes
  • 2 in conversation