Hello everyone,
i want to run the code based on certain conditions, lets say if the sex="M" then it will run the whole code
other wise it will run the other codes.
my code contain different macros and data step programs and sql quries as well.
Thanks in Advane
You can use next skiltom:
%macro(choose);
data _null_;
set any_data;
if <condition>
then call symput('flag',1);
else call symput('flag',0);
run;
%if &flag = 1 %then do;
<program 1>
%end; %else %do;
<program 2>
%end;
%mend;
%choose;
Does the condition relate to your data (where=(var=value)) or to external info (like date of run) ?
You can use next skiltom:
%macro(choose);
data _null_;
set any_data;
if <condition>
then call symput('flag',1);
else call symput('flag',0);
run;
%if &flag = 1 %then do;
<program 1>
%end; %else %do;
<program 2>
%end;
%mend;
%choose;
Can you show what type of code you are expecting to do this for?
Within a data step is one thing but if you need to do this with multiple procs and such that is another set of potential headaches.
other code
@shivamarrora0 wrote:
it can be either of 1 , what i want is to execute whole code on based on single condition, if the condition is false then i want to execute the other code
I am not sure what "either of 1" means in this context. And what is "whole code"? Examples go a long way to clarifying questions.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for 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.