I would do it slightly differently, using month (1-12) and year
(2002,2003,...) as numerical variables.
First the quarter is computed based solely on the month. Then 4 quarters
are added for each year after 2002.
This is the (untested) syntax - I don't see pitfalls, but I am counting on
the listfor extra eyes:
DO IF RANGE (MONTH,1,3) .
compute quarter= 1 .
ELSE IF RANGE (MONTH,4,6).
compute quarter= 2.
ELSE IF RANGE (MONTH,7,9).
compute quarter= 3.
ELSE IF RANGE (MONTH,10,12).
compute quarter= 4.
compute quarter = 0.
COMPUTE newquar= (YEAR - 2002)*4 + quarter.
From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of
Sent: Tuesday, July 06, 2004 3:57 PM
Subject: date coding syntax (self-updating)
I am importing dates from excel that need to be coded into 4 lots of
quarters. The periods are Jan1 to 31 March etc for four periods each year.
data is ongoing and needs to be updated on a regular basis. I have set up
recoding that looks like the following but as soon an new dates come in, the
recoding syntax needs to be re-adjusted because the most recent data from a
period are getting coded into the previous dates.
COMPUTE quarters=CTIME.DAYS(DATE.DMY(30,6,2004) - received)/365.25.
IF (quarters >=2.2587268993 & quarters <= 2.5 ) newquare = 1.
IF (quarters >= 2.0068446269 & quarters <= 2.2587) newquare = 2.
IF (quarters >=1.749 & quarters <= 2.00) newquare = 3.
IF (quarters >=1.497604 & quarters <= 1.746749) newquare = 4.
IF (quarters >=1.2511978096 & quarters <=1.4976039) newquare = 5.
IF (quarters >= 1.0020 & quarters <= 1.248460) newquare = 6.
IF (quarters >=.750 & quarters <= .999316) newquare = 7.
IF (quarters >= .49828 & quarters <= .747434) newquare = 8.
IF (quarters >= .0 & quarters <= .492814) newquare = 9.
VARIABLE LABELS newquare 'new quarters'.
value labels newquare
Since the data is ongoingly coming in, any advice on how to develop syntax
will contine to update irrespective of the year would be much appreciated.