Hello
It looks easy and i still do not know what is my mistake.
I want to create a new variable named FFOM. This variable will get value if founder (dummy variable 1/0) or secthird (dummy variable 1/0) is 1 and FOWNFF (countinous variable) >0.
This is my code:
data Y210517; set sasuser.y2;
ffom = if founder eq 1 or secthird eq 1 and fownff gt 0 then fownff;
run;
The log I got is:
Thanks for any clue...
Are you mixing up CASE and IF statements?
If youre assigning variables using THEN put the assignment at the end rather than at the beginning.
If <condition> then ffom = downfall;
Else ffom = other variable;
Are you mixing up CASE and IF statements?
If youre assigning variables using THEN put the assignment at the end rather than at the beginning.
If <condition> then ffom = downfall;
Else ffom = other variable;
Hi, another idea ...
data y2;
input founder secthird fownff @@;
datalines;
0 0 0 1 0 0 1 1 0 0 0 9 1 0 9 1 1 9
;
data y210517;
set y2;
ffom = (founder | secthird) * fownff;
run;
DATA SET: y210517
founder secthird fownff ffom
0 0 0 0
1 0 0 0
1 1 0 0
0 0 9 0
1 0 9 9
1 1 9 9
Mike's idea is logically clear.
or similar one like following in SAS. your statement is actually ambiguous.
_ffom = (founder eq 1 or secthird eq 1 and fownff gt 0 );
ffom=_ffom*fownff;
simple is best.
cheers.
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.
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.