Hi, I'm having trouble working with a restructured data set.
I've restructured my data from long to short (or wide) format. The restructure command seems to have worked well. There were 120 timepoints in the long-form data. As expected, it renamed the variable names according to the time points. So variable 'x' in the long-form dataset become variables 'x.0, x.1, x.2, x.3' and on to 'x.120' in the short-form dataset. And the same happens to variables y, z, etc. The problem is that I'm having trouble working with these new variable names. In particular, I want to be able to compute the maximum value of variables x.0 to x.120. However, the command compute xMax = Max(x.0 to x.120) returns the error '>A function argument list contains an invalid use of the TO convention. >Execution of this command stops.' This makes sense because 'x1 to x120' is not the same thing as 'x.1 to x.120'. Using syntax, however, I can't find an easy way around this. I could simply list out all of the variables (eg, Max(x.1, x.2, x.3...)), but I'm restructuring many variables, I have many additional variables to compute in the restructured dataset, and I want to make the syntax easy and flexible for other people to use. Is there any other way around this? Can you control how restructured variables are named? Would it be easiest to add in a rename command, and if so what might it look like? Or am I stuck writing out 120 variables every time that I want to do one of these calculations? Thanks for your help Josh ===================== 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
|
Take a look at the /SEPARATOR sub-command for CASESTOVARS. You can change the separator from the default "." to whatever you want, including a null string ("").
--
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 Josh
the TO convention works anchored at zero.
try this. data list list /x.0 to x.2. begin data 1 2 3 3 2 1 2 3 1 end data. frequencies variables = x.0 to x.2. look at the variables view. You say you should have 120 time points, but x.0 to x.120 is 121 variables. Also, are you sure the variables are in contiguous positions? Art Kendall Social Research Consultants On 1/24/2011 2:23 PM, Josh wrote: > Hi, I'm having trouble working with a restructured data set. > > I've restructured my data from long to short (or wide) format. The > restructure command seems to have worked well. There were 120 timepoints > in the long-form data. As expected, it renamed the variable names > according to the time points. So variable 'x' in the long-form dataset > become variables 'x.0, x.1, x.2, x.3' and on to 'x.120' in the short-form > dataset. And the same happens to variables y, z, etc. > > The problem is that I'm having trouble working with these new variable > names. In particular, I want to be able to compute the maximum value of > variables x.0 to x.120. However, the command > > compute xMax = Max(x.0 to x.120) > > returns the error > > '>A function argument list contains an invalid use of the TO convention. >> Execution of this command stops.' > This makes sense because 'x1 to x120' is not the same thing as 'x.1 to > x.120'. Using syntax, however, I can't find an easy way around this. > > I could simply list out all of the variables (eg, Max(x.1, x.2, x.3...)), > but I'm restructuring many variables, I have many additional variables to > compute in the restructured dataset, and I want to make the syntax easy > and flexible for other people to use. > > Is there any other way around this? Can you control how restructured > variables are named? Would it be easiest to add in a rename command, and > if so what might it look like? Or am I stuck writing out 120 variables > every time that I want to do one of these calculations? > > Thanks for your help > > Josh > > ===================== > 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
Art Kendall
Social Research Consultants |
In reply to this post by Josh
Perfect, that 'separator' subcommand was exactly what I was looking for.
Thanks! ===================== 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 |