DATA Step, Macro, Functions and more

SAS macro query

Accepted Solution Solved
Reply
Frequent Contributor
Frequent Contributor
Posts: 78
Accepted Solution

SAS macro query

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;


Accepted Solutions
Solution
‎11-16-2017 01:06 AM
Super User
Super User
Posts: 7,929

Re: SAS macro query

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


All Replies
Super User
Super User
Posts: 7,929

Re: SAS macro query

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.

 

Frequent Contributor
Frequent Contributor
Posts: 78

Re: SAS macro query

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;

 

Solution
‎11-16-2017 01:06 AM
Super User
Super User
Posts: 7,929

Re: SAS macro query

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;

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

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