BookmarkSubscribeRSS Feed
Kevin_Graduate
Calcite | Level 5
Hi, I am trying to find out why the data work.test2 has no observations, but both test3 and tes4 have c=1. Compared to test3, test2 misses one OUTPUT statement in the IF. Is this a problem? Clearly, the ELSE statement won't execute.


DATA work.test;
a=1;
b=2;
RUN;

DATA work.test2;
SET work.test;
IF a>0 THEN c=1;
ELSE
DO;
C=2;
OUTPUT;
END;
RUN;

DATA work.test3;
SET work.test;
IF a>0 THEN
DO;
c=1;
OUTPUT;
END;
ELSE
DO;
C=2;
OUTPUT;
END;
RUN;


DATA work.test4;
SET work.test;
IF a>0 THEN c=1;
ELSE
DO;
C=2;
END;
RUN;
4 REPLIES 4
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
You only have one explicit OUTPUT statement coded inside a DO/END.

Add this SAS statement at various points in your DATA step to analyze the processing by dumping all SAS variables to your SASLOG (change/identify each unique PUTLOG with the "nn" literal-constant):

PUTLOG '>DIAG-nn>' / _ALL_;


Scott Barry
SBBWorks, Inc.
Kevin_Graduate
Calcite | Level 5
It is very helpful to use the PUTLOG _ALL_ indeed. I tried.
Reeza
Super User
Yes this is a problem, output statements are defined at compile time I believe, not execution.

Once you have an explicit output statement there is no more implicit output and you need to have an output statement where you want an output.

As you noted the else statement won't execute so there won't be any output!.
Kevin_Graduate
Calcite | Level 5
Thanks for advice, Reeza.

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
  • 4 replies
  • 1113 views
  • 0 likes
  • 3 in conversation