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.
The put() function is one of those that are not available in %sysfunc and %qsysfunc.
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;
%SYSFUNC cannot be used with PUT. You have to switch to PUTN (in this case) or PUTC (in some cases) instead.
The put() function is one of those that are not available in %sysfunc and %qsysfunc.
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;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.