Help with selecting records - reply

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Help with selecting records - reply

thara vardhan-2
Dear Bruce, Garry, John F Hall and Joan Casellas

Thank you so much for helping me with the syntax for selecting records.

Bruce and Garry

The solution offered by both of you worked perfectly.

John - there is a problem with the DO If - function - looks like it does not like string variables.

I also tried by  recoding 'involvementtype' to a numeric. But still problems with Do If ...

I will try to run it again later when i have the time.    

Joan - I have many more variables in my data file based on which i have to do some more analysis so although I
did a test run on the syntax you sent me I cannot use it at the moment.

Again i will try and run it later when i have the time.

 However the method you have suggested actually has given me a clue about another problem i am facing with other data.

Thanks once again.

cheers
Thara Vardhan



_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

The information contained in this email is intended for the named recipient(s)
only. It may contain private, confidential, copyright or legally privileged
information. If you are not the intended recipient or you have received this
email by mistake, please reply to the author and delete this email immediately.
You must not copy, print, forward or distribute this email, nor place reliance
on its contents. This email and any attachment have been virus scanned. However,
you are requested to conduct a virus scan as well. No liability is accepted
for any loss or damage resulting from a computer virus, or resulting from a delay
or defect in transmission of this email or any attached file. This email does not
constitute a representation by the NSW Police Force unless the author is legally
entitled to do so.


Reply | Threaded
Open this post in threaded view
|

Re: Help with selecting records - reply

John F Hall

Thara

 

Looking back, I’m not sure if my logic was right for multiple (hierarchical) records with same caseid anyway.  Bruce’s trick of multiplying one value by 10 and adding it to another (for single digit values) is quite a common one, and can be extended for more variables using values of 10**n.  Are your data hierarchical?  If so, you should check out FILE TYPE under the DATA LIST command.

 

If the incidents were coded on the same data line, another way of picking up the codes is to use COUNT.

 

COUNT  V = InvolvementType (“VICTIM”)

          / P = InvolvementType (“PERSON OF INTEREST”) .

RECODE V P (2 THRU HI = 1).

COMPUTE NEWVAR = V*10 + P .

 

. . to yield NEWVAR with theoretical values 0,1,10,11 which you can then recode to taste.

 

All those long varnames will give you RSI if you have to keep typing them in:  I prefer short names, lower case and abbreviated syntax when creating the data file, and would use eg:

 

var lab v1 ‘Person CNI’ v2 ‘InvolvementType’ .

 

You could also think about AUTORECODE to change the string values to numeric (it does them in alphabetical order) and then use the strings as value labels.

 

autorecode  InvolvementType / into v3 .

val lab v3 1 ‘Person of interest’ 2 ‘Victim’ .

 

Since you are doing police work, I’ve copied this to Keith Bentley, a retired senior police officer, who currently holds lectureships in the Business School and the Criminology Faculties at the University of Salford.  He is a regular user of SPSS and specializes in the field of police intelligence systems.  I’m not sure if he’s on this list, but in October, he’s doing a 3-hour workshop on SPSS using the British Crime Survey (link is to abstract and coverage) for ASSESS (SPSS users in Europe) at York University.  I’ll forward the earlier thread to him.

 

John

 

[hidden email]

www.surveyresearch.weebly.com

 

 

 

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Thara Vardhan
Sent: 27 July 2011 04:47
To: [hidden email]
Subject: Help with selecting records - reply

 

Dear Bruce, Garry, John F Hall and Joan Casellas

Thank you so much for helping me with the syntax for selecting records.

Bruce and Garry

The solution offered by both of you worked perfectly.

John - there is a problem with the DO If - function - looks like it does not like string variables.

I also tried by  recoding 'involvementtype' to a numeric. But still problems with Do If ...

I will try to run it again later when i have the time.    

Joan - I have many more variables in my data file based on which i have to do some more analysis so although I
did a test run on the syntax you sent me I cannot use it at the moment.

Again i will try and run it later when i have the time.

 However the method you have suggested actually has given me a clue about another problem i am facing with other data.

Thanks once again.

cheers
Thara Vardhan


_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

The information contained in this email is intended for the named recipient(s)
only. It may contain private, confidential, copyright or legally privileged
information. If you are not the intended recipient or you have received this
email by mistake, please reply to the author and delete this email immediately.
You must not copy, print, forward or distribute this email, nor place reliance
on its contents. This email and any attachment have been virus scanned. However,
you are requested to conduct a virus scan as well. No liability is accepted
for any loss or damage resulting from a computer virus, or resulting from a delay
or defect in transmission of this email or any attached file. This email does not
constitute a representation by the NSW Police Force unless the author is legally
entitled to do so.

 

Reply | Threaded
Open this post in threaded view
|

Re: Help with selecting records - reply

David Marso
Administrator
In reply to this post by thara vardhan-2
I'm a little late to the game, but here is another bit which goes for the jugular ;-).
AGGREGATE OUTFILE *
   / MODE =ADDVARIABLES
   / BREAK PersonCNI
   / MINIT=MIN(InvolvementType)
   / MAXIT=MAX(InvolvementType).
STRING ROLE (A3).
IF MINIT = MAXIT ROLE=SUBSTR(MINIT,1,3).
IF MINIT <> MAXIT  ROLE="P&V".

AGGREGATE is just fine dealing with strings.  No need to muck around with any prior recode.
DO IF is also fine with strings if you don't botch the syntax ;-)...
Finally, if you can do any task without going long to wide then avoid CASESTOVARS or only do so at the end.  I would NOT spread the entire case, some people might have MANY MANY records (like the a$$hole who used to live down the street from me years ago when I lived in an uber-crappy neighborhood in Chicago) and you would create a variable for each record when you probably would really only want a count of each type.  So your typical case has say 10 records in the datafile and some A-hole has 100, you will end up creating 100 variables for each case, unnecessarily inflating the resulting file by a factor of 10.  ie If you have a million records you are adding 90M missing values!!!
HTH, David
--
--
Thara Vardhan wrote
Dear Bruce, Garry, John F Hall and Joan Casellas

Thank you so much for helping me with the syntax for selecting records.

Bruce and Garry

The solution offered by both of you worked perfectly.

John - there is a problem with the DO If - function - looks like it does
not like string variables.

I also tried by  recoding 'involvementtype' to a numeric. But still
problems with Do If ...

I will try to run it again later when i have the time.

Joan - I have many more variables in my data file based on which i have to
do some more analysis so although I
did a test run on the syntax you sent me I cannot use it at the moment.

Again i will try and run it later when i have the time.

 However the method you have suggested actually has given me a clue about
another problem i am facing with other data.

Thanks once again.

cheers
Thara Vardhan

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

The information contained in this email is intended for the named recipient(s)
only. It may contain private, confidential, copyright or legally privileged
information.  If you are not the intended recipient or you have received this
email by mistake, please reply to the author and delete this email immediately.
You must not copy, print, forward or distribute this email, nor place reliance
on its contents. This email and any attachment have been virus scanned. However,
you are requested to conduct a virus scan as well.  No liability is accepted
for any loss or damage resulting from a computer virus, or resulting from a delay
or defect in transmission of this email or any attached file. This email does not
constitute a representation by the NSW Police Force unless the author is legally
entitled to do so.
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"