Hi ,
Can someone suggest how to do the below.
have :
Table1;
Column1
AAAA
AAAE
AAAX
Want:
if 'AAAA' in Column1 then do %process1;
else if 'AAAE' in Column1 then do %process2;
else if 'AAAX' in Column1 then do %process3;
else %process4 ;
Presuming the DATA step is simply dispatching macros that perform other steps, and do not need to feedback to the running DATA step...
Use either
Example:
%NRSTR is used to stack all invocations until DATA step finishes.
data _null_;
set have;
select (Column1);
when ('AAAA') call execute ('%nrstr(%process1))'); /* or rc=dosubl('%process1'); */
when ('AAAE') call execute ('%nrstr(%process2))'); /* or rc=dosubl('%process2'); */
when ('AAAX') call execute ('%nrstr(%process3))'); /* or rc=dosubl('%process3'); */
otherwise call execute ('%nrstr(%process4))'); /* or rc=dosubl('%process4'); */
end;
run;
Presuming the DATA step is simply dispatching macros that perform other steps, and do not need to feedback to the running DATA step...
Use either
Example:
%NRSTR is used to stack all invocations until DATA step finishes.
data _null_;
set have;
select (Column1);
when ('AAAA') call execute ('%nrstr(%process1))'); /* or rc=dosubl('%process1'); */
when ('AAAE') call execute ('%nrstr(%process2))'); /* or rc=dosubl('%process2'); */
when ('AAAX') call execute ('%nrstr(%process3))'); /* or rc=dosubl('%process3'); */
otherwise call execute ('%nrstr(%process4))'); /* or rc=dosubl('%process4'); */
end;
run;
If the macros contain data step statements, then this is a possible syntax:
if COLUMN1='AAAA' then do; %process1; end;
else if COLUMN1='AAAE' then do; %process2; end;
else if COLUMN1='AAAX' then do; %process3; end;
else do; %process4; end;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.