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

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;
1 ACCEPTED SOLUTION

Accepted Solutions
kiranv_
Rhodochrosite | Level 12
IF ROLE_IN_REFERRAL in( 'x', 'y' , 'z')
THEN AGE_AT_RFRL_CHLD = age_at_referral;
ELSE AGE_AT_RFRL_CHLD = . ;

View solution in original post

3 REPLIES 3
TomKari
Onyx | Level 15

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

AnnaNZ
Quartz | Level 8

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

 

kiranv_
Rhodochrosite | Level 12
IF ROLE_IN_REFERRAL in( 'x', 'y' , 'z')
THEN AGE_AT_RFRL_CHLD = age_at_referral;
ELSE AGE_AT_RFRL_CHLD = . ;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to connect to databases in SAS Viya

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.

Discussion stats
  • 3 replies
  • 1922 views
  • 1 like
  • 3 in conversation