sub setting if

Accepted Solution Solved
Reply
Contributor
Posts: 43
Accepted Solution

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: 19,769

Re: sub setting if

Posted in reply to JVarghese

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;

View solution in original post


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

Re: sub setting if

Posted in reply to JVarghese

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.

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

Discussion stats
  • 2 replies
  • 184 views
  • 0 likes
  • 2 in conversation