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?
... View more