BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
scb
Obsidian | Level 7 scb
Obsidian | Level 7

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;

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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;

 

View solution in original post

3 REPLIES 3
Tom
Super User Tom
Super User

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.

 

scb
Obsidian | Level 7 scb
Obsidian | Level 7

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;

 

Tom
Super User Tom
Super User

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;

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1203 views
  • 0 likes
  • 2 in conversation