DATA Step, Macro, Functions and more

SAS Macro Question

Accepted Solution Solved
Reply
Regular Contributor
Posts: 173
Accepted Solution

SAS Macro Question

Hello Everyone,

I have a macro called Copy_Datasets.  It reads an input file and appends the word "holiday" to the end of the file name if today's date is one of the holidays defined in the holiday_file.  When I run the macro i get an error "Required operator not found in expression: &today. in (&Holiday_List.)" from the macro.   Does anyone have any suggestions as to how I can fix this issue?  I have listed my code below.  Thank you!

Data holiday_file;

input holidays dates9.;

datalines;

16jun2014

04jul2014

01sep2014

;

run;

proc sql;

select distinct holidays into : holiday_list

     seperated by ', '

     from holiday_file;

quit;

%Let today = $sysfunc(today());

%macro Copy_Datasets(infile);

%if &today. in (&holiday_list.) %then %do;

     data &infile._holiday;

     set &infile.;

     run;

%end;

%mend;

%Copy_Datasets(cust_file)


Accepted Solutions
Solution
‎06-16-2014 11:34 AM
SAS Employee
Posts: 15

Re: SAS Macro Question

Hello KevinC,

Is system option "minoperator" set?  See: SAS(R) 9.4 Macro Language: Reference

View solution in original post


All Replies
Super User
Posts: 17,829

Re: SAS Macro Question

%Let today = $sysfunc(today());

% instead of $ sign?

As well as dateS9 instead of date9 in the first input program.

Solution
‎06-16-2014 11:34 AM
SAS Employee
Posts: 15

Re: SAS Macro Question

Hello KevinC,

Is system option "minoperator" set?  See: SAS(R) 9.4 Macro Language: Reference

Regular Contributor
Posts: 173

Re: SAS Macro Question

Thank you all for your reply, I really appreciate it!

Jason,

I added the options minoperator and it resolved the issue.

Thank you everyone again Smiley Happy

Super User
Posts: 5,082

Re: SAS Macro Question

In addition to the other comments you already received, I believe that the macro version of the IN operator does not use parentheses around the list of values.

Respected Advisor
Posts: 3,777

Re: SAS Macro Question

The macro language is not well suited to the task of table look up.  Consider this approach which does not involve macro language.


data base; *example base data to recieve the word holiday;
  
set sashelp.class;
   run;

Data holiday_file(index=(holidays));
input holidays date9.;
datalines;
16jun2014
04jul2014
01sep2014
;
run;

data base;
   if 0 then modify base;
   holidays=today();
  
set holiday_file key=holidays;
   if _iorc_ ne 0 then stop;
   Name=
'Holiday';
  
output;
  
stop;
  
run;
Proc print data=base;
   run;

☑ This topic is SOLVED.

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

Discussion stats
  • 5 replies
  • 294 views
  • 0 likes
  • 5 in conversation