Quarter as a Count variable in 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 s开发者_Python百科tart) 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
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;
精彩评论