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
|
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 From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Thara Vardhan Dear Bruce, Garry, John F Hall and Joan Casellas
|
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 -- --
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?" |
Free forum by Nabble | Edit this page |