|
Hello,
I have a database where individuals are related. And each individual (id) has a reference person (idref). Everyone belongs to a group, but the reference person may belong to another group. I want to automate as to whether an individual and personal references are in the same group. In wanting to use the command DO REPEAT - END REPEAT I have stumbled upon the impossibility of using AGGREGATE. What to do? Let's say my variables are: Group: group identifier. Id: identification of the individual. Idref: identifying the reference person. I need your help. Thank you. . Ekoué KOUEVIDJIN Ingénieur Statisticien Technicien Supérieur en Electronique _____________________________________________________________________________ Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail ====================To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
|
At 10:41 AM 10/16/2007, Ekoué KOUEVIDJIN wrote:
>I have a database where individuals are related. >And each individual (id) has a reference person >(idref). Everyone belongs to a group, but the >reference person may belong to another group. I >want to automate as to whether an individual and >personal references are in the same group. >In wanting to use the command DO REPEAT - END >REPEAT I have stumbled upon the impossibility of using AGGREGATE. >Let's say my variables are: >Group: group identifier. >Id: identification of the individual. >Idref: identifying the reference person. You'll probably have seen that DO REPEAT/END REPEAT won't work at all. DO REPEAT only works across variables within a case; it can't compare across cases. AGGREGATE is a good idea, because it does compute across cases, but I don't think it's the right tool for you. You have to join the file to a copy of itself. The following assumes that your data is loaded, and that "RefTable" is a file reference or file handle that can be used to write a scratch .SAV file. Code is untested, and unfortunately complicated enough it could have problems. SORT CASES BY Id. SAVE OUTFILE = RefTable /RENAME= /RENAME=(Id Group Idref = Idref Groupref Discard) /KEEP = Idref Groupref. SORT CASES BY Idref Id. MATCH FILES /FILEL=* /TABLE=RefTable /BY Idref. SORT CASES BY Id. NUMERIC DiffGrp (F2). VAR LABEL DiffGrp 'In group different from reference person?'. VAL LABEL DiffGrp 0 'Same' 1 'Different'. COMPUTE DIFFGRP = (Group NE Groupref). ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
|
Follow-up and correction - At 02:09 PM 10/16/2007, I wrote:
>The following assumes that your data is loaded, and that "RefTable" is >a file reference or file handle that can be used to write a scratch >.SAV file. Code is untested, and unfortunately complicated enough it >could have problems. This is still not tested, but it corrects a couple of slips: SORT CASES BY Id. SAVE OUTFILE = RefTable /RENAME=(Id Group Idref = Idref Groupref Discard) /KEEP = Idref Groupref. SORT CASES BY Idref Id. MATCH FILES /FILE =* /TABLE=RefTable /BY Idref. SORT CASES BY Id. NUMERIC DiffGrp (F2). VAR LABEL DiffGrp 'In group different from reference person?'. VAL LABEL DiffGrp 0 'Same' 1 'Different'. COMPUTE DIFFGRP = (Group NE Groupref). ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
| Free forum by Nabble | Edit this page |
