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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.