Hi,
Can you help me with syntax that computes the count of each case when the last variable is unknown? Based on the data below, how do I figure out that ID = 11, has 7 variables; and ID = 12 has only 2 variables? I would like to get this count so I can use it in a loop to identify whether adjacent variables are the same or not. ID var1 var2 var3 var4 var5 var6 var7 11 1 1 1 1 1 1 1 12 1 2 13 1 1 2 3 14 2 1 3 1 1 15 1 2 2 3 1 1 Thanks very much. ===================== 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
|
The NVALID function is what you want.
COMPUTE NumValidVars = NVALID(var1 to var7). FORMATS NumValidVars(f2.0). FREQUENCIES NumValidVars.
--
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/). |
Use the COUNT command in place of COMPUTE.
On Sun, Nov 25, 2012 at 5:56 PM, Bruce Weaver <[hidden email]> wrote: The NVALID function is what you want. My pictures: http://picasaweb.google.com/vab88011
Twitter: vibeadle |
Administrator
|
Good morning ViAnn. I used COMPUTE with NVALID because I didn't know, and didn't need to know all of the possible valid values for Var1 to Var7. With COUNT, one would need to specify the valid values, IIRC. So what advantages does COUNT offer here?
Cheers, Bruce
--
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/). |
In reply to this post by SP
Thank you Bruce and ViAnn. I tried both COMPUTE and COUNT with the NVALID
function and COMPUTE did the trick. With the NumValidVars, I want to create a VECTOR vectorvar1 to vectorvar+NumValidVars but I'm having trouble using the CONCAT function to create the last variable. I e.g., If NumValidVars = 6, I would like declare VECTOR vectorvar1 to vectorvar6. Would CONCAT be the function to get vectorvar6? Thank you ===================== 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
|
You appear to be suggesting you want the vector size to vary by row. AFAIK, that is not possible. I think you'll need to set the vector size to the maximum number of valid values (across rows). You can use the row-specific NumValidValues as the maximum valid vector element for each row.
HTH.
--
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/). |
In reply to this post by Bruce Weaver
I was thinking of using keyword SYSMIS here given the sample data shown.
-----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Bruce Weaver Sent: Monday, November 26, 2012 6:04 AM To: [hidden email] Subject: Re: Compute the number of cells between variables when last variable is not constant Good morning ViAnn. I used COMPUTE with NVALID because I didn't know, and didn't need to know all of the possible valid values for Var1 to Var7. With COUNT, one would need to specify the valid values, IIRC. So what advantages does COUNT offer here? Cheers, Bruce ViAnn Beadle wrote > Use the COUNT command in place of COMPUTE. > > > On Sun, Nov 25, 2012 at 5:56 PM, Bruce Weaver < > bruce.weaver@ > >wrote: > >> The NVALID function is what you want. >> >> COMPUTE NumValidVars = NVALID(var1 to var7). >> FORMATS NumValidVars(f2.0). >> FREQUENCIES NumValidVars. >> >> >> >> S. P. wrote >> > Hi, >> > >> > Can you help me with syntax that computes the count of each case >> > when >> the >> > last variable is unknown? >> > Based on the data below, how do I figure out that ID = 11, has 7 >> > variables; and ID = 12 has only 2 variables? >> > >> > I would like to get this count so I can use it in a loop to >> > identify whether adjacent variables are the same or not. >> > >> > >> > >> > ID var1 var2 var3 var4 var5 var6 var7 >> > 11 1 1 1 1 1 1 1 >> > 12 1 2 >> > 13 1 1 2 3 >> > 14 2 1 3 1 1 >> > 15 1 2 2 3 1 1 >> > >> > Thanks very much. >> > >> > ===================== >> > 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 >> >> >> >> >> >> ----- >> -- >> Bruce Weaver >> > bweaver@ >> http://sites.google.com/a/lakeheadu.ca/bweaver/ >> >> "When all else fails, RTFM." >> >> NOTE: My Hotmail account is not monitored regularly. >> To send me an e-mail, please use the address shown above. >> >> -- >> View this message in context: >> http://spssx-discussion.1045642.n5.nabble.com/Compute-the-number-of-c >> ells-between-variables-when-last-variable-is-not-constant-tp5716448p5 >> 716450.html Sent from the SPSSX Discussion mailing list archive at >> Nabble.com. >> >> ===================== >> 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 >> > > > > -- > > My blog: lifeinnewmexico.wordpress.com My pictures: > http://picasaweb.google.com/vab88011 > Twitter: vibeadle ----- -- Bruce Weaver [hidden email] http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." NOTE: My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Compute-the-number-of-cells-be tween-variables-when-last-variable-is-not-constant-tp5716448p5716456.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 SP
What might the conditional statement look like if I wanted to set the row-
specific NumValidValues as the maximum vector element for each row? I've tried using this script to no avail: compute doors_switched = 0. FORMATS doors_switched(f2.0). COMPUTE Max_i = NVALID(var1 to var7). FORMATS Max_i(f2.0). loop #i = 1 to Max_i. - do IF (vectorvar(#i) ~= vectorvar(#i+1)). - compute doors_switched = doors_switched + 1. - ELSE. - compute doors_switched = doors_switched. - end if. end loop. execute. Thanks. On Mon, 26 Nov 2012 06:44:25 -0800, Bruce Weaver <[hidden email]> wrote: >You appear to be suggesting you want the vector size to vary by row. AFAIK, >that is not possible. I think you'll need to set the vector size to the >*maximum* number of valid values (across rows). You can use the >row-specific NumValidValues as the maximum valid vector element for each >row. > >HTH. > > > >S. P. wrote >> Thank you Bruce and ViAnn. I tried both COMPUTE and COUNT with the >> function and COMPUTE did the trick. >> >> With the NumValidVars, I want to create a VECTOR vectorvar1 to >> vectorvar+NumValidVars but I'm having trouble using the CONCAT function to >> create the last variable. I >> >> e.g., If NumValidVars = 6, I would like declare >> VECTOR vectorvar1 to vectorvar6. >> >> Would CONCAT be the function to get vectorvar6? >> >> Thank you >> >> ===================== >> 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 > > > > > >----- >-- >Bruce Weaver >[hidden email] >http://sites.google.com/a/lakeheadu.ca/bweaver/ > >"When all else fails, RTFM." > >NOTE: My Hotmail account is not monitored regularly. >To send me an e-mail, please use the address shown above. > >-- >View this message in context: http://spssx- variables-when-last-variable-is-not-constant-tp5716448p5716462.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 |
Administrator
|
Please define "to no avail"...
I see one or two problems. 1. If there are intermittent missing values your Max_i will be to no avail. 2. #i=1 TO Max_i and then using vectorvar(#i+1) ???? DING DING DING ???? ------- Perhaps loop #i=2 to max_i and compare V(#i) to V(#i-1) OTOH: What exactly are you trying to do here? -----
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 |