如何使用宏在SAS中获取当前月份名称和年份 [英] How to get current month name and year in SAS using macro

查看:66
本文介绍了如何使用宏在SAS中获取当前月份名称和年份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 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 &yearsuch 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆