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;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.