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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.