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-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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
  • 2455 views
  • 1 like
  • 3 in conversation