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

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)

1 ACCEPTED SOLUTION

Accepted Solutions
JasonAllen
SAS Employee

Hello KevinC,

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

View solution in original post

5 REPLIES 5
Reeza
Super User

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

% instead of $ sign?

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

JasonAllen
SAS Employee

Hello KevinC,

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

KevinC_
Fluorite | Level 6

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

Astounding
PROC Star

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.

data_null__
Jade | Level 19

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;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 5 replies
  • 918 views
  • 0 likes
  • 5 in conversation