Date: Fri, 29 Feb 2008 14:29:55 -0600
Reply-To: "Copeland, Laurel A" <copelandl@UTHSCSA.EDU>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Copeland, Laurel A" <copelandl@UTHSCSA.EDU>
Subject: Re: Quarters for Fiscal Years
In-Reply-To: <16FD64291482A34F995D2AF14A5C932C044F4D39@MAIL002.prod.ds.russell.com>
Content-Type: text/plain; charset="utf-8"
Ah - yes! Many thanks, Mark! -Laurel
-----Original Message-----
From: Terjeson, Mark [mailto:Mterjeson@russell.com]
Sent: Friday, February 29, 2008 2:13 PM
To: Copeland, Laurel A; SAS-L@LISTSERV.UGA.EDU
Subject: RE: Quarters for Fiscal Years
Hi Laurel,
Does this work better?
data x;
input id date date9. shouldbeq;
format date date9.;
cards;
100 30sep1999 4
101 01oct1999 1
101 02oct1999 1
101 30oct1999 1
102 31oct1999 1
103 30dec1999 1
103 31dec1999 1
104 01jan2000 2
105 30mar2000 2
105 31mar2000 2
106 01apr2000 3
107 30jun2000 3
107 01jul2000 4
108 01jul2002 4
108 02jul2002 4
109 29sep2003 4
109 30sep2003 4
110 01oct2003 1
111 30oct2003 1
111 31oct2003 1
111 01nov2003 1
112 31dec2003 1
;
run;
data y;
set x;
qstart = intnx('qtr',date,-3);
format qstart date9.;
q=qtr(qstart);
if shouldbeq NE q THEN flag='*';
run;
Hope this is helpful.
Mark Terjeson
Senior Programmer Analyst, IM&R
Russell Investments
Russell Investments
Global Leaders in Multi-Manager Investing
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Laurel A Copeland
Sent: Friday, February 29, 2008 12:03 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Quarters for Fiscal Years
I need to determine quarters for a fiscal year with a negative offset of three months. Our fiscal year begins three months before the calendar year of the same name, so that FY2000 begins in October 1999. I have gotten as far as is shown below, but can’t seem to get the adjustment for leap years right. I think it is leap years that are throwing the quarter off for certain end-of-quarter dates (see example below). I have many years of data to deal with.
I would appreciate your suggestions!
Thanks,
Laurel Copeland
San Antonio, Texas
*28FEB2008*extract FY QUARTER*;
*a leap year problem*;
*FY qtrs: 1=OND, 2=JFM, 3=AMJ, 4=JAS;
data x;
input id date date9. shouldbeq;
cards;
100 30sep1999 4
101 01oct1999 1
101 02oct1999 1
101 30oct1999 1
102 31oct1999 1
103 30dec1999 1
103 31dec1999 1
104 01jan2000 2
105 30mar2000 2
105 31mar2000 2
106 01apr2000 3
107 30jun2000 3
107 01jul2000 4
108 01jul2002 4
108 02jul2002 4
109 29sep2003 4
109 30sep2003 4
110 01oct2003 1
111 30oct2003 1
111 31oct2003 1
111 01nov2003 1
112 31dec2003 1
;
run;
proc print; format date date9.; run;
data y; set x; format date qstart date9.; qstart=intnx('year.10',date,0);
fy=year(qstart) + 1;
q=qtr(date-qstart);
if shouldbeq NE q THEN flag='*';
run;
proc print; run;