BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
yael
Quartz | Level 8

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:

SAS 2105.png

 

Thanks for any clue...

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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;

View solution in original post

3 REPLIES 3
Reeza
Super User

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;

MikeZdeb
Rhodochrosite | Level 12

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

 

 

fy1
Fluorite | Level 6 fy1
Fluorite | Level 6

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.

 

sas-innovate-2024.png

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.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1025 views
  • 3 likes
  • 4 in conversation