LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (July 2004)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Tue, 20 Jul 2004 18:37:29 -0400
Reply-To:   Raynald Levesque <rlevesque@videotron.ca>
Sender:   "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:   Raynald Levesque <rlevesque@videotron.ca>
Subject:   Re: Loops & variable names
In-Reply-To:   <80296325EC180043B1756C65684639C4048765E8@sagemsg0006.sagemsmrd01.sa.gov.au>
Content-type:   text/plain; charset=us-ascii

FYI

If the variables are not consecutive in the file, you can easily make them consecutive using the macro in file #4 of http://pages.infinit.net/rlevesqu/Macros.htm#MacroGems

Regards

Raynald Levesque rlevesque@videotron.ca Visit my SPSS site: http://pages.infinit.net/rlevesqu/

-----Original Message----- From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU]On Behalf Of Barnett, Adrian (HEALTH) Sent: July 20, 2004 2:26 AM To: SPSSX-L@LISTSERV.UGA.EDU Subject: Re: Loops & variable names

Hi Rob, If your offence date variables are contiguous in the file you could write a short DO REPEAT structure:

Do repeat X=OFFDATE.1 to OFFDATE.250. - if (x gt DATEADULT) OFFENCES_ADULT = OFFENCES_ADULT + 1. End repeat.

If these variables aren't contiguous, you will have a bit of typing in front of you, but you can probably do a bit of cut-and-paste from the output of a FILE>DISPLAY DATA FILE INFORMATION in the data editor to make this a bit easier

The code would be a tiny bit easier if each offence date was a new record, but the above is not too bad

Regards

Adrian

-- Adrian Barnett Research & Information Officer Ph: +61 8 82266615 Research, Analysis and Evaluation Fax: +61 8 82267088 Strategic Planning and Research Branch Strategic Planning and Population Health Division Department of Health email: Barnett.Adrian@saugov.sa.gov.au

God is good but don't dance in a currach. - Irish proverb

This e-mail may contain confidential information, which also may be legally privileged. Only the intended recipient(s) may access, use, distribute or copy this e-mail. If this e-mail is received in error, please inform the sender by return e-mail and delete the original. If there are doubts about the validity of this message, please contact the sender by telephone. It is the recipient's responsibility to check the e-mail and any attached files for viruses.

-----Original Message----- From: Potter, Robert (OCS) [mailto:Potter.Robert2@saugov.sa.gov.au] Sent: Tuesday, 20 July 2004 2:33 To: SPSSX-L@LISTSERV.UGA.EDU Subject: Loops & variable names

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


Back to: Top of message | Previous page | Main SPSSX-L page