[英]How to calculate month number in sas
Hi I need to calculate the value of month supposed in sas 01jan1960 is equal to 1 02jan1960 is equal to 2嗨,我需要计算 sas 中假设的月份值 01jan1960 等于 1 02jan1960 等于 2
So I need to calculate for 01aug2020 I used intck function but no output所以我需要计算 01aug2020 我使用了 intck 函数但没有输出
I want in datastep only .我只想要在 datastep 中。
SAS stores dates as the number of days since 1960 with zero representing first day of 1960. To represent a date in a program just use a quoted string followed by the letter D. The string needs to be something the DATE informat can interpret. SAS 将日期存储为自 1960 年以来的天数,零表示 1960 年的第一天。要在程序中表示日期,只需使用带引号的字符串后跟字母 D。该字符串需要是 DATE 信息可以解释的内容。
Let's run a little test.让我们运行一个小测试。
6 data _null_;
7 do dt=0 to 3,"01-JAN-1960"d,'01AUG2020'd;
8 put dt= +1 dt date9.;
9 end;
10 run;
dt=0 01JAN1960
dt=1 02JAN1960
dt=2 03JAN1960
dt=3 04JAN1960
dt=0 01JAN1960
dt=22128 01AUG2020
So the date value for '01AUG2020'd is 22,128.因此,'01AUG2020'd 的日期值为 22,128。
Subtraction works减法运算
days_interval = '01Aug2020'd - '01Jan1960'd;
Or looking at the unformatted value as SAS stores dates from 01Jan1960或者查看未格式化的值,因为 SAS 存储日期为 01Jan1960
days_interval = '01Aug2020'd;
format days_interval 8.;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.