Help using Base SAS procedures

Put a line between 2 groups

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 89
Accepted Solution

Put a line between 2 groups

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


Accepted Solutions
Solution
‎09-27-2011 09:52 AM
Super Contributor
Posts: 394

Put a line between 2 groups

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


All Replies
Solution
‎09-27-2011 09:52 AM
Super Contributor
Posts: 394

Put a line between 2 groups

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.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 123 views
  • 0 likes
  • 2 in conversation