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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

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