Is there anything wrong on the below codes, I just can't execute the below codes.
Anyone can help? Thanks.
FILENAME TEST "D:\SAS";
%LET T="T1";
%macro checkds;
%if &T EQ "T1" %then %do;
%INCLUDE TEST(TEST1.SAS);
%end;
%else %do;
%INCLUDE TEST(TEST2.SAS);
%end;
%mend checkds;
/***TEST1 AND TEST2 Program Codes***/
TEST1.SAS TEST2.SAS
DATA CARS; DATA SHOE;
SET SASHELP.CARS; SET SASHELP.SHOES;
RUN; RUN;
You still haven't tried to run it. All you did was redefine it.
To call a macro you put a % in front of the macro name. If your macro has parameter then add values for them inside of () after the macro's name.
%checkds;
You macro code looks valid.
All you have posted is code to define a fileref, a macro variable and a macro. But you didn't post any code that actually tried to run the macro.
Did you get any error messages when you tried to execute the macro? Post your SAS log.
There was no error message after i run ...just the codes.
517 FILENAME TEST "D:\SAS";
518
519 %LET T="T1";
520
521 %macro checkds;
522 %if &T EQ "T1" %then %do;
523 %INCLUDE TEST(TEST1.SAS);
524 %end;
525 %else %do;
526 %INCLUDE TEST(TEST2.SAS);
527 %end;
528 %mend checkds;
You still haven't tried to run it. All you did was redefine it.
To call a macro you put a % in front of the macro name. If your macro has parameter then add values for them inside of () after the macro's name.
%checkds;
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.