|
Hi there, I have a large dataset, but I'm interested in renaming
aseries of variables var00001 to var00019. riding_e var00001 .... to var00019. string value1 numeric numeric string value 2 string value 3 stringe value 4 I would like var00001 to be renamed string value 1, var00002 to be renamend string value 2, var00003 to be renamed string value 3. Can someone suggest a syntax for me? Simon Kiss ********************************* Simon J. Kiss, PhD SSHRC and DAAD Post-Doctoral Fellow John F. Kennedy Institute of North America Studies Free University of Berlin Lansstraße 7-9 14195 Berlin, Germany Cell: +49 (0)1525-300-2812, Web: http://www.jfki.fu-berlin.de/index.html ===================== 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 |
|
Dear Simon,
'string value 1' is not a valid variable name since it contains spaces. If I replace those by underscores, then
ren var (var00001 to var00019=string_value_1 to string_value_19)./*ren var=rename variables. Ruben van den Berg Methodologist TNS NIPO P: +31 20 522 5738 > Date: Mon, 25 Jan 2010 15:05:14 +0100 > From: [hidden email] > Subject: Rename variables with the string value in another variable? > To: [hidden email] > > Hi there, I have a large dataset, but I'm interested in renaming > aseries of variables var00001 to var00019. > riding_e var00001 .... to var00019. > string value1 numeric numeric > string value 2 > string value 3 > stringe value 4 > I would like var00001 to be renamed string value 1, var00002 to be > renamend string value 2, var00003 to be renamed string value 3. > > Can someone suggest a syntax for me? > Simon Kiss > > > ********************************* > Simon J. Kiss, PhD > SSHRC and DAAD Post-Doctoral Fellow > John F. Kennedy Institute of North America Studies > Free University of Berlin > Lansstraße 7-9 > 14195 Berlin, Germany > Cell: +49 (0)1525-300-2812, > Web: http://www.jfki.fu-berlin.de/index.html > > ===================== > 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 New Windows 7: Find the right PC for you. Learn more. |
|
Administrator
|
Ruben, I think what Simon meant was that the desired variable names appear in the RIDING_E column in the data file. Something along these lines should work, I think. new file. dataset close all. * Create a sample data set with only 3 variables . data list list / riding_e (a8) var1 to var3 (3f2.0). begin data "newvar1" 1 2 3 "newvar2" 3 1 2 "newvar3" 3 2 1 end data. string #case (a2). compute #case = ltrim(string($casenum,f1)). write outfile = "C:\temp\rename.txt" / "rename var(var", #case," = ", riding_e,")." . exe. include file = "C:\temp\rename.txt" . Cheers, Bruce p.s. - It would not surprise me if there's a nice Python-based solution too. ;-)
--
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 Simon Kiss
|
| Free forum by Nabble | Edit this page |
