| Date: | Tue, 20 Jul 2004 14:33:15 +0930 |
| Reply-To: | "Potter, Robert (OCS)" <Potter.Robert2@saugov.sa.gov.au> |
| Sender: | "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU> |
| From: | "Potter, Robert (OCS)" <Potter.Robert2@saugov.sa.gov.au> |
| Subject: | Loops & variable names |
| Content-Type: | text/plain; charset="iso-8859-1" |
|---|
I have a large file with about 270 variables that are defined as offdate.1
thru to offdate.250 plus a few other demographic things.
These are all offence dates listed for individuals across about 10 years.
What I want to do is compute a count of the number of offences each
individual commits after a certain date.
Can I do this within a loop or do I have to write 250 compute statements?
Basically the syntax goes;
IF (offdate.1 > dateadult) offences_adult = offences_adult + 1 .
VARIABLE LABELS offences_adult 'number of offences as an adult'.
EXECUTE .
IF (offdate.2 > dateadult) offences_adult = offences_adult + 1 .
VARIABLE LABELS offences_adult 'number of offences as an adult'.
EXECUTE .
.
.
.
.
IF (offdate.250 > dateadult) offences_adult = offences_adult + 1 .
VARIABLE LABELS offences_adult 'number of offences as an adult'.
EXECUTE .
Can I set up a loop that allows the loop number to define the variable name
IE - LOOP i=1 to 250
IF (offdate.i > dateadult) offences_adult = offences_adult + 1 .
VARIABLE LABELS offences_adult 'number of offences as an adult'.
EXECUTE .
END LOOP
|