SAS 中季度作为计数变量

发布于 2024-08-24 22:00:00 字数 210 浏览 2 评论 0原文

大家好,

我正忙于处理时间序列,并试图找到允许我插入四分之一计数变量的命令。为了简单起见,1995 年第三季度(我的观察开始的日期)应该是 -2 季度,1995 年第四季度应该是 -1 等等,直到 2006 年(那时应该在 45 左右)。我的日期采用 date9 格式,例如 20JUN04 等。

任何人都可以帮助我使用在 SAS 中运行所需的命令吗?

谢谢

Hye Guys,

I'm busy working on a time series and am trying to find the commands that allow me to insert a quarter count variable. To keep things simple, the third quarter of 1995 (date my observations start) should be quarter -2, the fourth quarter of 1995 should be -1 etc etc uptill 2006 (should be somewhere around 45 by then). My dates are in date9 format, such as 20JUN04 etc..

Anyone who can help me with the commands I need t o let this work in SAS?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

枕花眠 2024-08-31 22:00:00

SAS 有相当好的内置日期和日期时间函数。试试这个:

/* Some sample data */
data dates;
    format dateval date9.;
    informat dateval date9.;
    input dateval;
    datalines;
'01JUL95'
'01OCT95'
'01JAN96'
'20JUN04'
; 
run;

/* Sample of the intck function */
data _null_;
    set dates;
    quarter=intck('qtr','01JAN96'd,dateval);
    put _all_;
run;

SAS has pretty good built in date and datetime functions. Try this:

/* Some sample data */
data dates;
    format dateval date9.;
    informat dateval date9.;
    input dateval;
    datalines;
'01JUL95'
'01OCT95'
'01JAN96'
'20JUN04'
; 
run;

/* Sample of the intck function */
data _null_;
    set dates;
    quarter=intck('qtr','01JAN96'd,dateval);
    put _all_;
run;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文