|
Hi,
I am working with a large data set >3000 variables and I want to know if there is a quicker way to reorder variables than simply dragging them into the desired position. Any suggestions would be greatly appreciated. Anna -- **************************************************** Anna Woodcock M.A. Department of Psychological Sciences Purdue University 703 Third Street West Lafayette, IN 47907 Office: PSYC 2176 **************************************************** Do well and do good. |
|
Yes You can easily reorder variables by opening the file with a subset or new order to the variables using the keep command GET FILE='C: \cargiver.sav' /keep =ID PQUIETTM PGROUP PHOBBY PSOCIAL leisure_PART . DATASET NAME $DataSet WINDOW=FRONT. And or you can open the files and then save as a new file and use the keep command to save a subset and or reorder the variables. SAVE OUTFILE='C:\new order caregiver.sav' /keep =ID PQUIETTM PGROUP PHOBBY PSOCIAL leisure_PART /COMPRESSED. William N. Dudley, PhD Associate Dean for Research The School of Health and Human Performance Office of Research The University of North Carolina at Greensboro 126 HHP Building, PO Box 26170 Greensboro, NC 27402-6170 VOICE 336.2562475 FAX 336.334.3238
Hi, I am working with a large data set >3000 variables and I want to know if there is a quicker way to reorder variables than simply dragging them into the desired position. Any suggestions would be greatly appreciated. Anna -- **************************************************** Anna Woodcock M.A. Department of Psychological Sciences Purdue University 703 Third Street West Lafayette, IN 47907 Office: PSYC 2176 **************************************************** Do well and do good. |
|
Administrator
|
Re the second method, rather than saving and then re-opening the file, you can just use MATCH FILES (or ADD FILES), like this: GET FILE='C:\new order caregiver.sav' . MATCH FILES file = * / keep =ID PQUIETTM PGROUP PHOBBY PSOCIAL leisure_PART ALL . EXE. Note the keyword ALL at the end of the KEEP line. This will keep all other variables in their current order.
--
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 Anna Woodcock
At 09:34 AM 7/19/2009, Anna Woodcock wrote:
>I am working with a large data set >3000 variables and I want to >know if there is a quicker way to reorder variables than simply >dragging them into the desired position. William Dudley's right: look at the /KEEP subcommand, probably on GET FILE or SAVE OUTFILE=. If you're doing a /KEEP to reorder variables, it's a good idea to put keyword "ALL" at the end of the variable list. That will put any variables you left off your list at the end of the file, rather than losing them. And finally, I'd give at least one hard look to the organization of your data. 3,000 is a great many variables. Many datasets that size have repetitious groups of variables, with the same data for different participants, different office visits, etc. It's commonly wise to restructure so that each such participant, visit, etc., is in a separate record. That gives more cases and fewer variables, and SPSS handles that more gracefully. -Best wishes, Richard ===================== 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 Bruce Weaver
Hello,
I have a simple Python question. I want to make a custom menu button in spss dat activates a script that opens an explorer screen for each directory that is defined in a FILE HANDLE. The following code does not work, but it illustrates what I want. In this case, it should open one explorer instance that shows d:\temp. How can I make this work? import subprocess, os.path import spss, spssaux spss.Submit("file handle tmp /name = 'd:/temp'.") for handle in spssaux.getShow("handles"): if os.path.isdir(handle): subprocess.Popen("explorer " + handle) Thank you in advance for your time! Albert-Jan --- On Sun, 7/19/09, Bruce Weaver <[hidden email]> wrote: > From: Bruce Weaver <[hidden email]> > Subject: Re: Variable Reordering > To: [hidden email] > Date: Sunday, July 19, 2009, 4:33 PM > William Dudley WNDUDLEY wrote: > > > > Yes > > You can easily reorder variables by opening the file > with a subset or new > > order to the variables using the keep command > > > > GET > > FILE='C: \cargiver.sav' > > /keep =ID PQUIETTM PGROUP > PHOBBY PSOCIAL leisure_PART . > > DATASET NAME $DataSet WINDOW=FRONT. > > > > And or you can open the files and then save as a new > file and use the keep > > command to save a subset and or reorder the > variables. > > > > SAVE OUTFILE='C:\new order caregiver.sav' > > /keep =ID PQUIETTM PGROUP > PHOBBY PSOCIAL leisure_PART > > /COMPRESSED. > > > > > > Re the second method, rather than saving and then > re-opening the file, you > can just use MATCH FILES (or ADD FILES), like this: > > GET FILE='C:\new order caregiver.sav' . > > MATCH FILES > file = * / > keep =ID PQUIETTM PGROUP PHOBBY PSOCIAL leisure_PART > ALL . > EXE. > > Note the keyword ALL at the end of the KEEP line. > This will keep all other > variables in their current order. > > > ----- > -- > Bruce Weaver > [hidden email] > http://sites.google.com/a/lakeheadu.ca/bweaver/ > "When all else fails, RTFM." > > -- > View this message in context: http://www.nabble.com/Variable-Reordering-tp24557090p24557521.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 |
|
The getShow api only supports SHOW entries in the System Settings table. In order to make a version of getShow that would work with the File Handles table, make a version of the GetShow function with the following change.
For the EvaluateXPath expression use //pivotTable[@subType="File Handles"]/dimension/category/dimension/category/cell/@text That will select the File Handles table instead of the System Settings table. The rest of the filter is slightly different as well, since the structure of that table is a little different from the System Settings table. With Version 18, coming shortly, there is a new api and a new class named FileHandles in the spssaux module for managing file handle creation, retrieval, and resolving filespecs containing handles. Regards, Jon Peck -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Albert-Jan Roskam Sent: Monday, July 20, 2009 6:06 AM To: [hidden email] Subject: [SPSSX-L] spssaux.getShow("handles") Hello, I have a simple Python question. I want to make a custom menu button in spss dat activates a script that opens an explorer screen for each directory that is defined in a FILE HANDLE. The following code does not work, but it illustrates what I want. In this case, it should open one explorer instance that shows d:\temp. How can I make this work? import subprocess, os.path import spss, spssaux spss.Submit("file handle tmp /name = 'd:/temp'.") for handle in spssaux.getShow("handles"): if os.path.isdir(handle): subprocess.Popen("explorer " + handle) Thank you in advance for your time! Albert-Jan --- On Sun, 7/19/09, Bruce Weaver <[hidden email]> wrote: > From: Bruce Weaver <[hidden email]> > Subject: Re: Variable Reordering > To: [hidden email] > Date: Sunday, July 19, 2009, 4:33 PM > William Dudley WNDUDLEY wrote: > > > > Yes > > You can easily reorder variables by opening the file > with a subset or new > > order to the variables using the keep command > > > > GET > > FILE='C: \cargiver.sav' > > /keep =ID PQUIETTM PGROUP > PHOBBY PSOCIAL leisure_PART . > > DATASET NAME $DataSet WINDOW=FRONT. > > > > And or you can open the files and then save as a new > file and use the keep > > command to save a subset and or reorder the > variables. > > > > SAVE OUTFILE='C:\new order caregiver.sav' > > /keep =ID PQUIETTM PGROUP > PHOBBY PSOCIAL leisure_PART > > /COMPRESSED. > > > > > > Re the second method, rather than saving and then re-opening the file, > you can just use MATCH FILES (or ADD FILES), like this: > > GET FILE='C:\new order caregiver.sav' . > > MATCH FILES > file = * / > keep =ID PQUIETTM PGROUP PHOBBY PSOCIAL leisure_PART ALL . > EXE. > > Note the keyword ALL at the end of the KEEP line. > This will keep all other > variables in their current order. > > > ----- > -- > Bruce Weaver > [hidden email] > http://sites.google.com/a/lakeheadu.ca/bweaver/ > "When all else fails, RTFM." > > -- > View this message in context: > http://www.nabble.com/Variable-Reordering-tp24557090p24557521.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 ===================== 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 |
|
Thank you very much! I tried it and it works perfectly! I just added a custom button to the spss menu bar. Even though cutting and pasting the file path is not a whole lot of work, this is still very handy because I do it all the time. I pasted the code below so that other people could benefit from it.
Thanks again! Albert-Jan # in spssaux, modify the following function: def getShow(item): """Return the output for "item" as a string, where item is a SHOW command keyword. Item must appear in the System Settings table. For the few items where there are multiple fields, the fields are separated with ";". An empty string will be returned for an invalid keyword. """ tag, ignore = createXmlOutput("SHOW " + item + ".", "SHOW") # The xpath expression below is designed to work with all output languages result = ";".join(spss.EvaluateXPath(tag, '/', ## '//pivotTable[@subType="System Settings"]/dimension//category/dimension/category[2]/cell/@text')) # Old line '//pivotTable[@subType="File Handles"]/dimension/category/dimension/category/cell/@text')) # New line spss.DeleteXPathHandle(tag) return result # then save as e.g. spssaux_modified.py # Call the sps syntax below in the custom button. BEGIN PROGRAM. """ Program to use Windows Explorer to open all active SPSS file handles. """ import subprocess, os.path import spssaux_modified as m handles = m.getShow("handles").split(";") for handle in handles: if os.path.isdir(handle): subprocess.Popen("explorer " + handle) END PROGRAM. --- On Mon, 7/20/09, Peck, Jon <[hidden email]> wrote: > From: Peck, Jon <[hidden email]> > Subject: RE: [SPSSX-L] spssaux.getShow("handles") > To: "Albert-Jan Roskam" <[hidden email]>, [hidden email] > Date: Monday, July 20, 2009, 3:46 PM > The getShow api only supports SHOW > entries in the System Settings table. In order to make > a version of getShow that would work with the File Handles > table, make a version of the GetShow function with the > following change. > > For the EvaluateXPath expression use > > //pivotTable[@subType="File > Handles"]/dimension/category/dimension/category/cell/@text > > That will select the File Handles table instead of the > System Settings table. The rest of the filter is > slightly different as well, since the structure of that > table is a little different from the System Settings table. > > With Version 18, coming shortly, there is a new api and a > new class named FileHandles in the spssaux module for > managing file handle creation, retrieval, and resolving > filespecs containing handles. > > Regards, > Jon Peck > > -----Original Message----- > From: SPSSX(r) Discussion [mailto:[hidden email]] > On Behalf Of Albert-Jan Roskam > Sent: Monday, July 20, 2009 6:06 AM > To: [hidden email] > Subject: [SPSSX-L] spssaux.getShow("handles") > > Hello, > > I have a simple Python question. I want to make a custom > menu button in spss dat activates a script that opens an > explorer screen for each directory that is defined in a FILE > HANDLE. The following code does not work, but it illustrates > what I want. In this case, it should open one explorer > instance that shows d:\temp. How can I make this work? > > import subprocess, os.path > import spss, spssaux > spss.Submit("file handle tmp /name = 'd:/temp'.") > for handle in spssaux.getShow("handles"): > if os.path.isdir(handle): > subprocess.Popen("explorer " + > handle) > > Thank you in advance for your time! > > Albert-Jan > > > --- On Sun, 7/19/09, Bruce Weaver <[hidden email]> > wrote: > > > From: Bruce Weaver <[hidden email]> > > Subject: Re: Variable Reordering > > To: [hidden email] > > Date: Sunday, July 19, 2009, 4:33 PM > > William Dudley WNDUDLEY wrote: > > > > > > Yes > > > You can easily reorder variables by opening the > file > > with a subset or new > > > order to the variables using the keep > command > > > > > > GET > > > FILE='C: \cargiver.sav' > > > /keep =ID PQUIETTM PGROUP > > PHOBBY PSOCIAL leisure_PART . > > > DATASET NAME $DataSet WINDOW=FRONT. > > > > > > And or you can open the files and then save as a > new > > file and use the keep > > > command to save a subset and or reorder the > > variables. > > > > > > SAVE OUTFILE='C:\new order caregiver.sav' > > > /keep =ID PQUIETTM PGROUP > > PHOBBY PSOCIAL leisure_PART > > > /COMPRESSED. > > > > > > > > > > Re the second method, rather than saving and then > re-opening the file, > > you can just use MATCH FILES (or ADD FILES), like > this: > > > > GET FILE='C:\new order caregiver.sav' . > > > > MATCH FILES > > file = * / > > keep =ID PQUIETTM PGROUP PHOBBY PSOCIAL > leisure_PART ALL . > > EXE. > > > > Note the keyword ALL at the end of the KEEP line. > > This will keep all other > > variables in their current order. > > > > > > ----- > > -- > > Bruce Weaver > > [hidden email] > > http://sites.google.com/a/lakeheadu.ca/bweaver/ > > "When all else fails, RTFM." > > > > -- > > View this message in context: > > http://www.nabble.com/Variable-Reordering-tp24557090p24557521.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 > ===================== 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 |
