BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
biglerc
Obsidian | Level 7

Hi everyone,

 

I am creating a macro variable that holds a date, and I want to have it display as a date9 format to be used in a title.  My code is:


%global cutdt ;
%global cutdtc;
%let cutdt = %sysfunc(mdy(08,15,2024));
%let cutdtc = %sysfunc(inputn(&cutdt, yymmdd10.), date9.);

 

However, my log gives me the following messages:


5033 %global cutdt ;
5034 %global cutdtc;
5035 %let cutdt = %sysfunc(mdy(08,15,2024));
5036 %let cutdtc = %sysfunc(inputn(&cutdt, yymmdd10.), date9.);
WARNING: Argument 1 to function INPUTN referenced by the %SYSFUNC or %QSYSFUNC macro function is
out of range.
NOTE: Mathematical operations could not be performed during %SYSFUNC function execution. The
result of the operations have been set to a missing value.

Can anyone help me troubleshoot my issue in line 5036?  I appreciate any help!  Thanks!

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

The %SYSFUNC() macro function allows you to specify the format to use when converting the value generated by the function it is calling into text to be passed back.

%let cutdt = %sysfunc(mdy(08,15,2024),date9.);

Your mistake was treating the digits string representing the integer value SAS uses for 15AUG2014 as if it was in YYYY-MM-DD style by trying to read it with the YYMMDD10. informat.  If you did want to use the PUTN() format to format a date value there is no need to change the integer value into some other representation. 

%let cutdt = %sysfunc(mdy(08,15,2024));
%let cutdtc = %sysfunc(putN(&cutdt, date9.));

Note that if you do have your macro variable in DATE9 style you can easily use it in places where you need an actual date value by using it to generate a date literal.

%let cutdt = %sysfunc(mdy(08,15,2024),date9.);
title "Data before &cutdt";
proc print data=have;
  where date < "&cutdt"d ;
run;

 

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

The %SYSFUNC() macro function allows you to specify the format to use when converting the value generated by the function it is calling into text to be passed back.

%let cutdt = %sysfunc(mdy(08,15,2024),date9.);

Your mistake was treating the digits string representing the integer value SAS uses for 15AUG2014 as if it was in YYYY-MM-DD style by trying to read it with the YYMMDD10. informat.  If you did want to use the PUTN() format to format a date value there is no need to change the integer value into some other representation. 

%let cutdt = %sysfunc(mdy(08,15,2024));
%let cutdtc = %sysfunc(putN(&cutdt, date9.));

Note that if you do have your macro variable in DATE9 style you can easily use it in places where you need an actual date value by using it to generate a date literal.

%let cutdt = %sysfunc(mdy(08,15,2024),date9.);
title "Data before &cutdt";
proc print data=have;
  where date < "&cutdt"d ;
run;

 

biglerc
Obsidian | Level 7

Thank you, Tom!  That was a wonderful and clear explanation! I have learned something super useful today.  

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 811 views
  • 0 likes
  • 2 in conversation