|
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.
ELSE .
compute quarter = 0.
END IF.
COMPUTE newquar= (YEAR - 2002)*4 + quarter.
HTH -
-----Original Message-----
From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of
Paul Dickson
Sent: Tuesday, July 06, 2004 3:57 PM
To: SPSSX-L@LISTSERV.UGA.EDU
Subject: date coding syntax (self-updating)
Hi servers,
I am importing dates from excel that need to be coded into 4 lots of
3-monthly
quarters. The periods are Jan1 to 31 March etc for four periods each year.
The
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
new
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.
execute.
VARIABLE LABELS newquare 'new quarters'.
value labels newquare
1 'Jan-March(2002)'
2 'Apr-Jun(2002)'
3 'Jul-Sep(2002)'
4 'Oct-Dec(2002)'
5 'Jan-March(2003)'
6 'Apr-Jun(2003)'
7 'Jul-Sep(2003)'
8 'Oct-Dec2003'
9 'Jan-Mar(2004)'.
execute.
Since the data is ongoingly coming in, any advice on how to develop syntax
that
will contine to update irrespective of the year would be much appreciated.
Regards Paul
|