Just to be clear, you have a character variable called Result which contains a string like "(C1='y' and b1='N' and a1='y')" ?
http://www2.sas.com/proceedings/sugi30/001-30.pdf
This paper walks through how to recode variables using a format. It's well written and clear.
Another standard way to recode is IF/THEN statements.
C1 is your variable name, so you want to rename your variables.
You'll need something like:
data WANT;
set HAVE(rename=(C1=CUSTOMER1
B1=CUSTOMERB)
);
RESULT=(CUSTOMER1 ='Y' & CUSTOMERB='N' );
run;
Your explanations were not clear. Always show : this is what I have & this is what I want.
Like this?
data WANT;
length RESULT $1000;
RESULT= "(C1='y' and b1='N' and a1='y')" ;
RESULT=transtrn(RESULT,'C1=','CUSTOMER1=');
RESULT=transtrn(RESULT,'b1=','CUSTOMERB=');
putlog RESULT=;
run;
RESULT=(CUSTOMER1='y' and CUSTOMERB='N' and a1='y')
Don't forget to make your string longer.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.
Ready to level-up your skills? Choose your own adventure.