I want to create a new variable based on specidif conditions. If the conditions are met, I want that new variable to carry the value that is in a different variable:
Example
IF (ROLE_IN_REFERRAL = 'x' or ROLE_IN_REFERRAL = 'y' or ROLE_IN_REFERRAL = 'z') THEN AGE_AT_RFRL_CHLD = use the value(in this case the age) that is in variable: (age_at_referral)
ELSE AGE_AT_RFRL_CHLD = . ; run;
IF ROLE_IN_REFERRAL in( 'x', 'y' , 'z') THEN AGE_AT_RFRL_CHLD = age_at_referral;
ELSE AGE_AT_RFRL_CHLD = . ;
This is pretty straightforward, but two questions first:
1. Which SAS environment are you trying to do this in (Base SAS, Enterprise Guide, DI Studio, ...).
2. It looks like ROLE_IN_REFERRAL is character, and age_at_referral and AGE_AT_RFRL_CHILD are both numeric. Please confirm.
Tom
Hi Tom
I work with SAS9.4
and yes ROLE_IN_REFERRAL is character, and age_at_referral and AGE_AT_RFRL_CHILD are both numeric
IF ROLE_IN_REFERRAL in( 'x', 'y' , 'z') THEN AGE_AT_RFRL_CHLD = age_at_referral;
ELSE AGE_AT_RFRL_CHLD = . ;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.