How could I change this to work wiht the and?
if V > 1then C ='Door' and D='Window";
else if V < 1 then C='Door2' and D2 = 'Window2".
if v>1 then do;
c='Door';
d='window';
end;
else do;
c='Door2';
d='window2';
end;
What if I have something like this :
if V > 1then C ='Door' and D='Window";
else if V > 2 then C='Door2' and D2 = 'Window2"
else if V > 3 then C='Door3' and D= 'Window3':
AND is usually restricted to the logical operator in programming languages.
You are using AND in the sense of THIS AND ALSO THE OTHER. In programming languages you usually use some type of grouping syntax to say that two or more things should go together. In SAS you would use DO; ... END; statements to do this grouping. (Also match sure to match your quotes properly)
if V > 1 then do; C ='Door' ; D='Window'; end;
else if V > 2 then do; C='Door2'; D2 = 'Window2'; end;
else if V > 3 then do; C='Door3'; D= 'Window3'; end;
Hi Tom,
I think your code should be:
data have;
input v @@;
cards;
1 2 3 4 5 6
;
data want;
set have;
if V > 3 then do; C='Door3'; D= 'Window3'; end;
else if V > 2 then do; C='Door2'; D = 'Window2'; end;
else if V > 1 then do; C ='Door' ; D='Window'; end;
run;
proc print;run;
Obs v C D
1 1
2 2 Door Window
3 3 Door2 Window2
4 4 Door3 Window3
5 5 Door3 Window3
6 6 Door3 Window3
Thank you!
Linlin
Thanks. I just copied the code from above and put in DO; END; statements.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.