Sample programs to execute simple logical conditions in SAS macros

sas
macros
data_wrangling

#1

Hi all,
anyone please give me the code of simple logical expressions sample programs in macros like,
%if %then %else,
%if %then %do --------- %end %else %do-------%end,
%do %while,
%do %until;
and etc.
as im getting very confused in these topics.

Regards,
sahil.


#2

Hi,

Please go through the below mentioned pdf-
http://www2.sas.com/proceedings/sugi31/039-31.pdf

Hope this helps.

Regards,
Aayush Agrawal


#3

@zubairsahil
You can look at the below syntax for conditional and iterative statements:
Conditional Statements:

Single True or False statement execution:-

%IF <Conditional Macro Expression> %THEN <TRUE statements>;
%ELSE <FALSE Statements>;

Multiple True or False statements execution:-

%IF <Conditional Macro Expression> %THEN %DO;
<TRUE statement-1>;
<TRUE statement-2>;
.
.
<TRUE statement-n>;
%End;
%ELSE %DO;
<TRUE statement-1>;
<TRUE statement-2>;
.
.
<TRUE statement-n>;
%End;

For detail explanation with case study you can refer below link.

Regards,
Sunil