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;

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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