k***@cox.net
2007-01-24 18:31:19 UTC
I'm trying to add a suffix (e.g., '_99') to all my variable names. I
tried to use the syntax below (which I got from:
http://pages.infinit.net/rlevesqu/Syntax/LabelsAndVariableNames/Add_99AtEndOfAllVariableNames.txt)
but I'm getting an error.
Here's the syntax:
**************.
*** Add _99 to the end of existing variable names.
*** Of course existing variable names are assumed to have
*** at most 5 characters.
**************.
DATA LIST LIST /v1 vara varz a2345 a3456.
BEGIN DATA.
1 1 1 1 1
END DATA.
SAVE OUTFILE='c:\temp\mydata.sav'.
FLIP.
STRING newname(A8).
* The last letter of var names having 8 characters are deleted.
* unless this would result in a name duplication.
COMPUTE newname=CONCAT(RTRIM(case_lbl),'_99').
WRITE OUTFILE='c:\temp\rename.sps'
/ 'RENAME VARIABLE ('case_lbl'='newname').'.
Execute.
GET FILE='c:\temp\mydata.sav'.
INCLUDE 'C:\temp\rename.sps'.
***********
(Since I already have my dataset and variables in SPSS, I started the
syntax at the STRING command.)
When I run the syntax as is, I get an error on case_lbl (Incorrect
variable name ...). What does case_lbl represent, and what do I need to
change it to for the syntax to work. My dataset has approximately 100
variables, and I just need to suffix them with '_99'.
And as an aside, I'm confused over this comment:
*** Of course existing variable names are assumed to have
*** at most 5 characters.
But the datalist used in the example includes three variables (v1,
vara, varz) that have less than 5 characters.
Thanks for any help.
Kurt
tried to use the syntax below (which I got from:
http://pages.infinit.net/rlevesqu/Syntax/LabelsAndVariableNames/Add_99AtEndOfAllVariableNames.txt)
but I'm getting an error.
Here's the syntax:
**************.
*** Add _99 to the end of existing variable names.
*** Of course existing variable names are assumed to have
*** at most 5 characters.
**************.
DATA LIST LIST /v1 vara varz a2345 a3456.
BEGIN DATA.
1 1 1 1 1
END DATA.
SAVE OUTFILE='c:\temp\mydata.sav'.
FLIP.
STRING newname(A8).
* The last letter of var names having 8 characters are deleted.
* unless this would result in a name duplication.
COMPUTE newname=CONCAT(RTRIM(case_lbl),'_99').
WRITE OUTFILE='c:\temp\rename.sps'
/ 'RENAME VARIABLE ('case_lbl'='newname').'.
Execute.
GET FILE='c:\temp\mydata.sav'.
INCLUDE 'C:\temp\rename.sps'.
***********
(Since I already have my dataset and variables in SPSS, I started the
syntax at the STRING command.)
When I run the syntax as is, I get an error on case_lbl (Incorrect
variable name ...). What does case_lbl represent, and what do I need to
change it to for the syntax to work. My dataset has approximately 100
variables, and I just need to suffix them with '_99'.
And as an aside, I'm confused over this comment:
*** Of course existing variable names are assumed to have
*** at most 5 characters.
But the datalist used in the example includes three variables (v1,
vara, varz) that have less than 5 characters.
Thanks for any help.
Kurt