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

I am trying to convert the date variable in a macro into a character variable called "label".

 

%let date=%qsysfunc(intnx(month, '31Oct2017'd, 2));


But the following gives errors. Any idea how to achieve this?

 

%let label=%sysfunc(put(&date, date9.));

ERROR: The PUT function referenced in the %SYSFUNC or %QSYSFUNC macro function is not found.

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

The put() function is one of those that are not available in %sysfunc and %qsysfunc.

See here: http://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.2&docsetId=mcrolref&docsetTarget=p1o1...

Use the putn() function instead:

%let date=%sysfunc(intnx(month, '31Oct2017'd, 2));

%let label=%sysfunc(putn(&date,date9.));
%put &label;

or do it in one step:

%let label=%sysfunc(intnx(month, '31Oct2017'd, 2),date9.);

%put &label;

View solution in original post

2 REPLIES 2
Astounding
PROC Star

%SYSFUNC cannot be used with PUT.  You have to switch to PUTN (in this case) or PUTC (in some cases) instead.

Kurt_Bremser
Super User

The put() function is one of those that are not available in %sysfunc and %qsysfunc.

See here: http://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.2&docsetId=mcrolref&docsetTarget=p1o1...

Use the putn() function instead:

%let date=%sysfunc(intnx(month, '31Oct2017'd, 2));

%let label=%sysfunc(putn(&date,date9.));
%put &label;

or do it in one step:

%let label=%sysfunc(intnx(month, '31Oct2017'd, 2),date9.);

%put &label;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 2 replies
  • 7676 views
  • 0 likes
  • 3 in conversation