Hi Listserv, I have a database in longitudinal format. For example:1 0 1 1 1 1 1 2 1 2 0 0 2 1 1 2 2 0 3 0 1 3 1 1 4 1 1 5 2 1 6 2 0 Leah |
I think this will work. Aggregate outfile=* mode=addvariables/break=id/nr=nu/ones=sum(factor). If (nr eq nu) ones=1. If (nr ne nu) ones=0. Gene Maguin From: SPSSX(r) Discussion [mailto:[hidden email]]
On Behalf Of Leah Rubin Hi Listserv, I have a database in longitudinal format. For example: ID Wave Factor What I am trying to do is create a new variable whereby individuals are given a 1 only if the "factor" variable is the same across all waves of data. So for example, ID 1 for all waves of data has a "1" for
the "factor" variable. Therefore, in the new variable I would like them to be coded a 1. For ID 2 for example they have a mixture of 1's and 0's for the factor variable and therefore I would like to denote them a 0.
Can someone please help me with this code? Thanks in advance for your help, Leah ===================== 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
|
Administrator
|
Gene,
What if the factor value is NOT 1? Instead: Use MIN and MAX functions in the aggregate and compare them. Alternatively use SD and compare to 0 ?
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?" |
I understand your point. I looked at the example data and saw only 0 and 1 and so went the way I did. My little scheme will fail if factor can have a value other than 0 or 1. Gene Maguin
-----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of David Marso Sent: Wednesday, May 11, 2016 10:58 AM To: [hidden email] Subject: Re: help with selecting cases Gene, What if the factor value is NOT 1? Instead: Use MIN and MAX functions in the aggregate and compare them. Alternatively use SD and compare to 0 ? Maguin, Eugene wrote > I think this will work. > Aggregate outfile=* mode=addvariables/break=id/nr=nu/ones=sum(factor). > If (nr eq nu) ones=1. > If (nr ne nu) ones=0. > > Gene Maguin > > > From: SPSSX(r) Discussion [mailto: > SPSSX-L@.UGA > ] On Behalf Of Leah Rubin > Sent: Wednesday, May 11, 2016 10:25 AM > To: > SPSSX-L@.UGA > Subject: help with selecting cases > > Hi Listserv, > I have a database in longitudinal format. For example: > ID Wave Factor > 1 0 1 > 1 1 1 > 1 2 1 > 2 0 0 > 2 1 1 > 2 2 0 > 3 0 1 > 3 1 1 > 4 1 1 > 5 2 1 > 6 2 0 > What I am trying to do is create a new variable whereby individuals > are given a 1 only if the "factor" variable is the same across all > waves of data. So for example, ID 1 for all waves of data has a "1" > for the "factor" variable. Therefore, in the new variable I would like > them to be coded a 1. For ID 2 for example they have a mixture of 1's > and 0's for the factor variable and therefore I would like to denote them a 0. > Can someone please help me with this code? > Thanks in advance for your help, > Leah > ===================== To manage your subscription to SPSSX-L, send a > message to > LISTSERV@.UGA > <mailto: > LISTSERV@.UGA > > (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 > > ===================== > To manage your subscription to SPSSX-L, send a message to > LISTSERV@.UGA > (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 ----- 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?" -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/help-with-selecting-cases-tp5732132p5732136.html Sent from the SPSSX Discussion mailing list archive at Nabble.com. ===================== 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 ===================== 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 |
In reply to this post by David Marso
[about noting an unchanging score]
=====================
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
This question has come up several times. It finally occurs to me that I don't know who wants it, or why. But it does seem to me, now, that MIN and MAX offer a step towards whatever-may-be-wanted-next. That is, given MIN and MAX, one or the other might be of special interest. Does the person EVER (NEVER) show X-behavior? And you can take (MAX-MIN) to get the amount of variation, where other small amounts near zero (or, huge amounts) might be of occasional interest, rather than merely change/ no change. -- Rich Ulrich > Date: Wed, 11 May 2016 07:57:48 -0700 > From: [hidden email] > Subject: Re: help with selecting cases > To: [hidden email] > > Gene, > What if the factor value is NOT 1? > Instead: > Use MIN and MAX functions in the aggregate and compare them. > Alternatively use SD and compare to 0 ? > > > Maguin, Eugene wrote > > I think this will work. > > Aggregate outfile=* mode=addvariables/break=id/nr=nu/ones=sum(factor). > > If (nr eq nu) ones=1. > > If (nr ne nu) ones=0. > > |
Administrator
|
In reply to this post by David Marso
I was thinking AGGREGATE with SD here too. But when I tried it, I discovered you have to watch out for the cases where Ss have only one wave. SD is missing that case, and if you don't treat the missing value correctly, you'll get the wrong value for your flag variable. Notice the inclusion of MISSING on the RECODE line below.
NEW FILE. DATASET CLOSE all. DATA LIST list / ID Wave Factor (3F2.0). BEGIN DATA 1 0 1 1 1 1 1 2 1 2 0 0 2 1 1 2 2 0 3 0 1 3 1 1 4 1 1 5 2 1 6 2 0 END DATA. AGGREGATE /OUTFILE=* MODE=ADDVARIABLES OVERWRITE=YES /BREAK=ID /SDF=SD(Factor) /MinF=MIN(Factor) /MaxF=MAX(Factor) . RECODE SDF (0 MISSING = 1) (ELSE = 0) into CF1. COMPUTE CF2 = MinF EQ MaxF. FORMATS CF1 CF2 (F1). LIST. Output: ID Wave Factor SDF MinF MaxF CF1 CF2 1 0 1 .00 1 1 1 1 1 1 1 .00 1 1 1 1 1 2 1 .00 1 1 1 1 2 0 0 .58 0 1 0 0 2 1 1 .58 0 1 0 0 2 2 0 .58 0 1 0 0 3 0 1 .00 1 1 1 1 3 1 1 .00 1 1 1 1 4 1 1 . 1 1 1 1 5 2 1 . 1 1 1 1 6 2 0 . 0 0 1 1
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
Free forum by Nabble | Edit this page |