May I know what wrong with the macro below as I can't get the T1 dataset? Thanks.
%LET PERIODE=01sep2018;
%LET TODATE ="10sep2018"D;
DATA _NULL_;
IF INTCK('DAY',"&PERIODE"D,&TODATE.) ge 8
THEN call symputx("T", "T1");
ELSE call symputx("T", "T2");
RUN;
%PUT T=&T;
%macro check(dsn);
%if T = "&dsn" %then %do;
DATA T1;
SET SASHELP.CARS;
IF MAKE EQ 'BMW';
RUN;
%end;
%else %do;
DATA T2;
SET SASHELP.CARS;
RUN;
%end;
%mend check;
%check(T1);
%if T = "&dsn" %then %do;
In this macro statement, you compare the string
T
with a string that (as the macro is called later) is
"T1"
note the presence and absence of quotes.
What you probably wanted:
%if &T = &dsn %then %do;
The macro preprocessor does not need quotes when comparing strings, as everything is a string for it.
Hi,
Try changing your %if condition to:
%if T1 = &dsn %then %do;
Regards,
Amir.
"May I know what wrong with the macro below " - its all in upper case, no use of the code window {i}, so code is next to impossible to read, no log provided to explain what is "wrong". (all mentioned previously).
At a guess I would say:
%if T
is your problem as macro variables need an & before, and should also for good coding have a . afterwards.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.