SAS Weekday Function Error - Mainframe SAS

Reply
Contributor
Posts: 74

SAS Weekday Function Error - Mainframe SAS

I am getting an error when I use this code on a mainframe SAS session but not when I use EG.  How do I edit this so I do not get an error on mainframe?

I am using this in a macro that wraps around a process so that it will not run on Sundays unless the Sunday is the first day of a month.

Thanks,

DATA _NULL_;                                                     

WOD=TODAY()-1;                                                   

CALL SYMPUT("TODAY",PUT(WOD-1,YYMMDDN8.));

RUN;                                                             

                                                                  

DATA _NULL_;                                                     

FORMAT VAR 1.;

IF WEEKDAY(TODAY()) IN (2,3,4,5,6,7) THEN VAR = 1;               

ELSE IF WEEKDAY(&TODAY) = 1 AND DAY(&TODAY) = 1 THEN VAR = 1;    

ELSE VAR = 0;

CALL SYMPUT("RUNVAR",VAR);                                       

RUN;       

NOTE: Numeric values have been converted to character                         

      values at the places given by: (Line)Smiley SadColumn).                         

      17:23                                                                   

NOTE: Invalid argument to function WEEKDAY at line 15 column 10.              

ERROR: Limit set by ERRORS= option reached.  Further errors of this type will 

ERROR: Limit set by ERRORS= option reached.  Further errors of this type will 

ERROR: Limit set by ERRORS= option reached.  Further errors of this type will 

       not be printed.

       not be printed.                                                        

       not be printed.                                                        

VAR=0 _ERROR_=1 _N_=1     

Super User
Posts: 7,760

Re: SAS Weekday Function Error - Mainframe SAS

The argument for the weekday() function needs to be a SAS date value. SAS stores dates as numbers, counting the days from 01jan1960.

In

CALL SYMPUT("TODAY",PUT(WOD-1,YYMMDDN8.));

you assigned yesterdays date in the format 20150510 to your macro variable, which is a) not numeric and b) would be too far in the future if numeric.

Instead of YYMMDDN8. you can simply use BEST6. to assign the raw number to the macro variable.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Ask a Question
Discussion stats
  • 1 reply
  • 267 views
  • 0 likes
  • 2 in conversation