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.
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.
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.