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.
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 lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.