problem creating variables cross-referencing another member of a couple

14 messages
Open this post in threaded view
|

problem creating variables cross-referencing another member of a couple

 Hello people, For a time series study on couples, we'd like to create new set of variables for each person corresponding to the "partner's score" on a set of variables.Couples were asked to make diary entries on their mood and other things, and we'd like to have a variable for the person's mood and then their partner's mood at the equivalent time, for example.We have a variable for each person's entry (1-60 entries), their couple (1-4 couples), and another variable just specifying whether they are member 1 or member 2 in that couple (a variable called 'member'). Then we have a set of 51 variables we'd like to examine. I've pasted in the syntax and then the error message below. Any help / ideas would be much appreciated!Many Thanks,Russell DeightonThe syntax:vector v = happy TO both_unhelpaction.vector newvar(51).SORT CASES BY couple entry member (A).LOOP #n = 1 to 51.IF entry = LAG(entry) newvar(#n)=LAG(v(#n)).IF (entry <> LAG(entry) OR MISSING(LAG(entry))=1) newvar(#n)=(v(#n+1)).END LOOP.EXECUTE.The error message:>Error # 4030 in column 23.  Text: newvar >The operand appearing on the left side of the assignment operator (equals >sign) is not a known vector name or function name. >Execution of this command stops. IF (entry <> LAG(entry) OR MISSING(LAG(entry))=1) newvar(#n)=(v(#n+1)).  >Error # 4030 in column 51.  Text: newvar >The operand appearing on the left side of the assignment operator (equals >sign) is not a known vector name or function name. >Execution of this command stops. END LOOP. EXECUTE. ===================== 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
Open this post in threaded view
|

Re: problem creating variables cross-referencing another member of a couple

 Administrator The VECTOR declarations must be placed AFTER the SORT CASES command. I have no idea what this is supposed to do.   IF (entry <> LAG(entry) OR MISSING(LAG(entry))=1) newvar(#n)=(v(#n+1)). Definitely NOT what you intend. You might find it easier to do this using the MATRIX language. UNTESTED: SORT CASES BY couple entry member (A). MATRIX. GET ids /FILE */VARIABLES couple entry member. GET scores /FILE */VARIABLES happy TO both_unhelpaction. COMPUTE newvars=MAKE(NROW (scores),NCOL (scores),0). LOOP #=1 TO NROW (scores)-1. DO IF ids(#,1:2)= ids(#+1,1:2). COMPUTE newvars(#,:)=scores(#+1,:). COMPUTE newvars(#+1,:)=scores(#,:). END IF. END LOOP. SAVE {ids ,scores ,newvars}   /OUTFILE *   /VARIABLES  couple entry member scores01 TO scores51 Othrscores01 TO Othrscores51. END MATRIX. RENAME VARIABLES (up to you here.......). Hello people, For a time series study on couples, we'd like to create new set of variables for each person corresponding to the "partner's score" on a set of variables. Couples were asked to make diary entries on their mood and other things, and we'd like to have a variable for the person's mood and then their partner's mood at the equivalent time, for example. We have a variable for each person's entry (1-60 entries), their couple (1-4 couples), and another variable just specifying whether they are member 1 or member 2 in that couple (a variable called 'member'). Then we have a set of 51 variables we'd like to examine. I've pasted in the syntax and then the error message below. Any help / ideas would be much appreciated! Many Thanks, Russell Deighton The syntax: vector v = happy TO both_unhelpaction. vector newvar(51). SORT CASES BY couple entry member (A). LOOP #n = 1 to 51. IF entry = LAG(entry) newvar(#n)=LAG(v(#n)). IF (entry <> LAG(entry) OR MISSING(LAG(entry))=1) newvar(#n)=(v(#n+1)). END LOOP. EXECUTE. The error message: >Error # 4030 in column 23.  Text: newvar >The operand appearing on the left side of the assignment operator (equals >sign) is not a known vector name or function name. >Execution of this command stops. IF (entry <> LAG(entry) OR MISSING(LAG(entry))=1) newvar(#n)=(v(#n+1)). >Error # 4030 in column 51.  Text: newvar >The operand appearing on the left side of the assignment operator (equals >sign) is not a known vector name or function name. >Execution of this command stops. END LOOP. EXECUTE. ===================== 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?" -- Sent from: http://spssx-discussion.1045642.n5.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 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?"
Open this post in threaded view
|

Re: problem creating variables cross-referencing another member of a couple

Open this post in threaded view
|

Re: problem creating variables cross-referencing another member of a couple

Open this post in threaded view
|

Re: problem creating variables cross-referencing another member of a couple

Open this post in threaded view
|

Re: problem creating variables cross-referencing another member of a couple

Open this post in threaded view
|

Re: problem creating variables cross-referencing another member of a couple

Open this post in threaded view
|

Re: problem creating variables cross-referencing another member of a couple

 In reply to this post by R Deighton I would follow this straight-forward logic:  1. XSAVE after IF and after ELSE  to write 2 files, a separate file for each partner;  2. RENAME (during the save) the variables for partner 2 (or, for both);  3. Match the two files.   - you see \$SYSMIS if the other record was not there. -- Rich Ulrich From: SPSSX(r) Discussion <[hidden email]> on behalf of R Deighton <[hidden email]> Sent: Monday, October 23, 2017 7:29:39 PM To: [hidden email] Subject: problem creating variables cross-referencing another member of a couple   Hello people, For a time series study on couples, we'd like to create new set of variables for each person corresponding to the "partner's score" on a set of variables. Couples were asked to make diary entries on their mood and other things, and we'd like to have a variable for the person's mood and then their partner's mood at the equivalent time, for example. We have a variable for each person's entry (1-60 entries), their couple (1-4 couples), and another variable just specifying whether they are member 1 or member 2 in that couple (a variable called 'member'). Then we have a set of 51 variables we'd like to examine. I've pasted in the syntax and then the error message below. Any help / ideas would be much appreciated! Many Thanks, Russell Deighton The syntax: vector v = happy TO both_unhelpaction. vector newvar(51). SORT CASES BY couple entry member (A). LOOP #n = 1 to 51. IF entry = LAG(entry) newvar(#n)=LAG(v(#n)). IF (entry <> LAG(entry) OR MISSING(LAG(entry))=1) newvar(#n)=(v(#n+1)). END LOOP. EXECUTE. The error message: >Error # 4030 in column 23.  Text: newvar >The operand appearing on the left side of the assignment operator (equals >sign) is not a known vector name or function name. >Execution of this command stops. IF (entry <> LAG(entry) OR MISSING(LAG(entry))=1) newvar(#n)=(v(#n+1)).   >Error # 4030 in column 51.  Text: newvar >The operand appearing on the left side of the assignment operator (equals >sign) is not a known vector name or function name. >Execution of this command stops. END LOOP. EXECUTE. -- Sent from: http://spssx-discussion.1045642.n5.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
Open this post in threaded view
|

Re: problem creating variables cross-referencing another member of a couple

Open this post in threaded view
|

Re: problem creating variables cross-referencing another member of a couple

Open this post in threaded view
|

Re: problem creating variables cross-referencing another member of a couple

Open this post in threaded view
|

Re: problem creating variables cross-referencing another member of a couple

 Many thanks people! That's such a great help! I was obviously way off track. The python code was above my head, but I really appreciate the elegance of it. The data set is now as hope for, so I'm very grateful. Russell -- Sent from: http://spssx-discussion.1045642.n5.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