Solved
Contributor
Posts: 43

# sub setting if

data test;

infile sample;

input a 1-2 b \$ 3-6;

if a=12;

c=a*2;

run;

What happens to the obsrvation with a^=12? Is it deleted altogether? Why is it not output to test with c =null value?How subsetting if statement functions as to conditional if then/else statement?

Accepted Solutions
Solution
‎03-06-2014 05:02 PM
Super User
Posts: 23,700

## Re: sub setting if

Yes it is deleted. if statements with no then statements are effectively:

if a=12 then continue, else delete statements.

If you want to operate conditionally then use:

if a=12 then do;

c=a*2;

end;

OR in this case because you only have one statement:

if a=12 then c=a*2;

All Replies
Solution
‎03-06-2014 05:02 PM
Super User
Posts: 23,700

## Re: sub setting if

Yes it is deleted. if statements with no then statements are effectively:

if a=12 then continue, else delete statements.

If you want to operate conditionally then use:

if a=12 then do;

c=a*2;

end;

OR in this case because you only have one statement:

if a=12 then c=a*2;

Contributor
Posts: 43

## Re: sub setting if

Thanks Reeza

🔒 This topic is solved and locked.