如何使用宏在 SAS 中获取当前月份名称和年份 [英] How to get current month name and year in SAS using macro
问题描述
我正在触发 SAS 中的邮件,该邮件应包含当前月份和年份
I am triggering a mail in SAS which should holds current month and year in the mail
我怎样才能创建宏变量&month
&year
这样
How can I create macro variables &month
&year
such that
&month
应该显示十月&year
应该显示 2020
&month
should display October&year
should display 2020
正在使用
%let sysmonth= %sysfunc(month("&sysdate"d));
%let sysyear= %sysfunc(year("&sysdate"d));
%put &sysmonth &sysyear;
但我得到了月份的数字,但我想要用文字表达的月份
But I am getting month in number but i want the month in words
推荐答案
%SYSFUNC
有一个可选的第二个参数来指定格式.在此处的特定情况下,您实际上并不需要它-Richard 的 PUTN 也可以正常工作-但如果您确实希望函数运行,这是该示例-此处的示例用于如果您想要与当前一个,但任何功能都以这种方式工作.
%SYSFUNC
has an optional second argument that specifies format. In the particular case here you don't really need it - Richard's PUTN works just as well - but in the case that you do want a function to operate, here's that example - the example here being for if you want a different month than the current one, but any function works this way.
%let sysmonth= %sysfunc(intnx(month,"&sysdate"d,-1),monname.);
%put &=sysmonth;
这篇关于如何使用宏在 SAS 中获取当前月份名称和年份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!