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

Hello Forum,

I the following code, "if  0 then" do?

Thanks.

data base;

if 0 then modify base;

set one two e04 open=defer;

output;

run;

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Suppose I am writing code per some directions from the boss and he says "We'll need to modify this table but the conditions wont' be set until the meeting next week." I know that I'll have to provide for handling that condition, which could be quite complex, but I don't know what it is at the time I start coding the pieces I do have requirements for. I put the stub of code you're asking about as a reminder of where in the process I need to implement that condition.

View solution in original post

4 REPLIES 4
ballardw
Super User

0 is treated by SAS in logical comparisons as FALSE. So basically the code says not to do anything as the part following THEN only executes when the comparison is true.

This may be a programmer holding bit for testing other logic or does not know the conditions that will be needed but knows the conditional part will be needed later.

kaushal2040
Calcite | Level 5

Thanks ballardw,

So the code says do not modify the base data set?   I was wondering what " but knows the conditional part will be needed later'"  mean in your last sentence.

ballardw
Super User

Suppose I am writing code per some directions from the boss and he says "We'll need to modify this table but the conditions wont' be set until the meeting next week." I know that I'll have to provide for handling that condition, which could be quite complex, but I don't know what it is at the time I start coding the pieces I do have requirements for. I put the stub of code you're asking about as a reminder of where in the process I need to implement that condition.

Tom
Super User Tom
Super User

The program basically appends datasets ONE TWO and E04 to the end of the dataset BASE.

The "IF 0 THEN" does absolutely nothing in this case.  If you remove it and just have the MODIFY statement the code runs the same.

This construct is sometimes used with a SET statement instead of a MODIFY statement.  The effect then is that the compiler sees the SET statement and adds the variables in the referenced data set to the data vector but the IF 0 THEN causes the SET statement to never execute.  It is a quick way to make sure your new dataset has the same variables.

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!

How to Concatenate Values

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.

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
  • 965 views
  • 0 likes
  • 3 in conversation