%IF-%THEN... | IF-THEN... |
---|---|
is used only in a macro program. | is used only in a DATA step program. |
executes during macro execution. | executes during DATA step execution. |
uses macro variables in logical expressions and cannot refer to DATA step variables in logical expressions. | uses DATA step variables in logical expressions. |
determines what text should be copied to the input stack. | determines what DATA step statement(s) should be executed. When inside a macro definition, it is copied to the input stack as text. |
You can control text that is copied to the input stack with the
status
determines which variables will be included in the new data set. The value of the data set variable Location
determines the value of the new data set variable Totalfee
. %macro choice(status);
data fees;
set sasuser.all;
%if &status=PAID %then %do;
where paid='Y';
keep student_name course_code begin_date totalfee;
%end;
%else %do;
where paid='N';
keep student_name course_code
begin_date totalfee latechg;
latechg=fee*.10;
%end;
/* add local surcharge */
if location='Boston' then totalfee=fee*1.06;
else if location='Seattle' then totalfee=fee*1.025;
else if location='Dallas' then totalfee=fee*1.05;
run;
%mend choice;
Just pay attention, if you use macro variables, then you should use "%if %then".
.
No comments:
Post a Comment