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

I want to create a new variable called new var 

conditions for recoding are:

if var1 = 'A' and all other var2 - var5 are blank then newvar = A;

if var1 = 'A' and any of the var2-var5 are B and nothing else in the vars (should be blank) then newvar = AB

if var1='A' and var2= 'R' then newvar but all other vars should be null or blank = AR;

 

 

VAR1VAR2VAR3VAR4VAR5VAR6Newvar
A     A
AB    AB
A B   AB
A  B  AB
A   B AB
AR    AR
ABR   ABR
ARR   ARR
A  R  AR

 

Basically I need help with how to tell if statement to make sure that the combination is correct provided all other variables are null.

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

What about 

 

x=CATT(of var1-var6);

 

View solution in original post

8 REPLIES 8
Reeza
Super User

Is your second last record correct or should it be ARR?

AZIQ1
Quartz | Level 8

Yes it should be ARR.

Thank you.

Reeza
Super User

@AZIQ1 wrote:

Yes.


That's an or question not a yes/no question. Please take the time to detail your question and answers otherwise why should we take the time to answer them. 

AZIQ1
Quartz | Level 8

Sorry, my bad, yes it should be ARR.

Reeza
Super User

You should post samples that include what happen in other conditions, ie what if they're not blank. 

AZIQ1
Quartz | Level 8

Thank you - it should  be "unknown" if none of the conditions meet.

 

Thanks

Reeza
Super User

What about 

 

x=CATT(of var1-var6);

 

AZIQ1
Quartz | Level 8
Thank you so much.

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 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
  • 8 replies
  • 1368 views
  • 1 like
  • 2 in conversation