Hi all,
data test ;
length have want $1000.;
HAVE='WHERE aeout like "%RECOVERED%";';
WANT="if find(aeout , 'RECOVERED' ,'i') >0;";
output;
HAVE='where aeout not like "%RECOVERED%" and aeacn like "%DOSE%";';
WANT="if not find(aeout,'RECOVERED','i')>0 and find(aeacn,'DOSE','i')> 0";
output;
HAVE='WHERE aeout not like "%RECOVERED%" and aeacn not like "%DOSE%" and not (aeacn like "%DRUG%" or AEPRA = "Y");';
WANT="if not find(aeout,'RECOVERED','i')>0 and not find(aeacn,'DOSE','i')>0 and not (find(aeacn,'DRUG','i')>0 or AEPRA = 'Y');";
output;
run ;
As per my specification all the conditions/logics were given in compatible with SQL statements , and based on that condition have to create new variable. The condition (present in HAVE variable) works prefectly uisng PROC SQL , CASE when statements ( for creating new varaible) . But my macro was already designed for data step if then else statements , so i cannot use the above statement(HAVE) in my macro. I am trying to convert that SQL compatible statement in to if then else statement
as present in WANT statement. All the condition are present in one data step , i have to convert them automatically into if then else compatible statement so that i can use them (WANT) in my macro without any modifications.
I am trying to convert the HAVE statement (PROC SQL compatible syntax) into WANT statement (Data step if -then else statement) in SAS automatically. Any suggestions how to convert it automatically through SAS as standardization process?
Hello @keen_sas,
Your question requires more details before experts can help. Can you revise your question to include more information?
Review this checklist:
To edit your original message, select the "blue gear" icon at the top of the message and select Edit Message. From there you can adjust the title and add more details to the body of the message. Or, simply reply to this message with any additional information you can supply.
SAS experts are eager to help -- help them by providing as much detail as you can.
This prewritten response was triggered for you by fellow SAS Support Communities member @ballardw
.A data step can have WHERE statements. If you have multiple WHERE statements chain them with an WHERE SAME AND or add & between the criteria's and remove the word WHERE.
data have;
set sashelp.class;
where name like 'A%';
where same and age in (12:18);
run;
or replace the WHERE with an AND. I would also add parenthesis to ensure correct resolution of your criteria's.
data have;
set sashelp.class;
where (name like 'A%')
/*WHERE*/ and (age in (12:18));
run;
@keen_sas wrote:
Hi all,
data test ;
length have want $1000.;
HAVE='WHERE aeout like "%RECOVERED%";';
WANT="if find(aeout , 'RECOVERED' ,'i') >0;";
output;
HAVE='where aeout not like "%RECOVERED%" and aeacn like "%DOSE%";';
WANT="if not find(aeout,'RECOVERED','i')>0 and find(aeacn,'DOSE','i')> 0";
output;
HAVE='WHERE aeout not like "%RECOVERED%" and aeacn not like "%DOSE%" and not (aeacn like "%DRUG%" or AEPRA = "Y");';
WANT="if not find(aeout,'RECOVERED','i')>0 and not find(aeacn,'DOSE','i')>0 and not (find(aeacn,'DRUG','i')>0 or AEPRA = 'Y');";
output;run ;
As per my specification all the conditions/logics were given in compatible with SQL statements , and based on that condition have to create new variable. The condition (present in HAVE variable) works prefectly uisng PROC SQL , CASE when statements ( for creating new varaible) . But my macro was already designed for data step if then else statements , so i cannot use the above statement(HAVE) in my macro. I am trying to convert that SQL compatible statement in to if then else statement
as present in WANT statement. All the condition are present in one data step , i have to convert them automatically into if then else compatible statement so that i can use them (WANT) in my macro without any modifications.I am trying to convert the HAVE statement (PROC SQL compatible syntax) into WANT statement (Data step if -then else statement) in SAS automatically. Any suggestions how to convert it automatically through SAS as standardization process?
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.