Trouble formatting macro date variable

  • Follow


I wonder if some clever list member can tell me the simple mistake I am
making here:

%let three_days_ago = %eval (%sysfunc(today ()) - 3);
%let datestring = %sysfunc (input (three_days_ago, mmddyy10.));
%put &datestring;

The error message reads "ERROR: The INPUT function referenced in the
%SYSFUNC or %QSYSFUNC macro function is not found."

0
Reply paulvonhippel (114) 7/5/2006 9:47:18 PM

You can't use put or input functions in %SYSFUNC.  (It's in the
manual).

You can use a datastep for the same results:

data _null_;
 call symputx('three_days_ago',today()-3);
 call symputx('datestring',put(today()-3,mmddyy10.));
run;

%put &three_days_ago;
%put &datestring;

NB: I'm pretty sure you'll wan to to use a put, not an input.


Paul wrote:
> I wonder if some clever list member can tell me the simple mistake I am
> making here:
>
> %let three_days_ago = %eval (%sysfunc(today ()) - 3);
> %let datestring = %sysfunc (input (three_days_ago, mmddyy10.));
> %put &datestring;
>
> The error message reads "ERROR: The INPUT function referenced in the
> %SYSFUNC or %QSYSFUNC macro function is not found."

0
Reply davidschr (69) 7/6/2006 2:12:23 AM


Paul,

The SAS help indicates the following:
SAS Functions Not Available with %SYSFUNC and %QSYSFUNC:
DIF DIM HBOUND IORCMSG INPUT LAG LBOUND MISSING PUT RESOLVE SYMGET and
All Variable Information Functions

But it also provides an alternative:
Note:    Instead of INPUT and PUT, which are not available with
%SYSFUNC and %QSYSFUNC, use INPUTN, INPUTC, PUTN, and PUTC in Screen
Control Language

Furthermore I noticed that you dit not have the ampersand (&) in front
of the macro variable you are using in the input function.
In short if you would not like to use the suggested datastep, the
following should do the trick:
%let three_days_ago = %eval (%sysfunc(today ()) - 3);
%let datestring = %sysfunc (putn (&three_days_ago, mmddyy10.));
%put &datestring ;

I tried this on July 6 and in the log the following was returned:
07/03/2006

Kind regards and good luck.


Paul schreef:

> I wonder if some clever list member can tell me the simple mistake I am
> making here:
>
> %let three_days_ago = %eval (%sysfunc(today ()) - 3);
> %let datestring = %sysfunc (input (three_days_ago, mmddyy10.));
> %put &datestring;
>
> The error message reads "ERROR: The INPUT function referenced in the
> %SYSFUNC or %QSYSFUNC macro function is not found."

0
Reply rdrijsen (6) 7/6/2006 7:48:43 AM

2 Replies
92 Views

(page loaded in 0.079 seconds)


Reply: