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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.