|
Dear all,
I'm sorry to bother the list again but I just can't figure this out: I'm trying to add the suffix "_R" to all my variable names in the file. For most variables, it works fine but for some the suffix is reduced to just "_" instead of "_R". I don't see any systematic difference between the ones that work and the ones that don't. Unfortunately, this causes the next syntax to break down (some variables ending with "_" are not found because they're specified in the syntax as ending with "_R"). Could anyone please have a look? TIA once again!! GET FIL 'RvB_1.sav'. DATAS NAM RvB_1. DATAS DEC VarsRvB. OMS /SEL TAB /IF COM=['File Information'] sub=['Variable Information'] /DES FOR=SAV OUTFILE=VarsRvB VIE=NO. DISP VAR. OMSEND. DATAS ACT VarsRvB. *SAV OUT 'VARS_RvB.sav' */COM. *SHOW DIR. STR Suff (A2). STR Newname(A11). STR Sps (A200). COMP Suff="_R". COMP Newname=CONCAT(RTRIM(Var1),Suff). COMP Sps=CONCAT("REN VAR ",RTRIM(Var1),"=",RTRIM(Newname)). EXE. SAV TRA OUT '2A2_REN_VAR_R.sps' /TYP TAB /KEE Sps /REP. See all the ways you can stay connected to friends and family |
|
Ruben - Total
shot in the dark, but older versions of SPSS require variable names to be 8
characters or less. Maybe the '_R' puts some variables over 8
characters? I use 11.5 and I'm restricted to 8 characters. The
change to longer var names was made in v12 or v13, I
believe.
Peter
Link
VA San Diego
Healthcare System
|
|
In reply to this post by Ruben Geert van den Berg
A guess: the original variable names are longer than you expected.
try something like this untested syntax. compute howlong = length (RTRIM(Var1)). frequencies vars = howlong. Btw, it is often more useful in the long run to use prefixes rather than suffixes. Suggestion to SPSS. It would be a nice feature for the syntax editor if it expanded abbreviations. Art Kendall Social Research Consultants Ruben van den Berg wrote: Dear all,
Art Kendall
Social Research Consultants |
|
Indeed, that was it! Increasing the length of Newname to (A15) just did the trick!
Thx a lot once again! Kind regards, Ruben Date: Wed, 20 May 2009 13:02:53 -0400 From: [hidden email] Subject: Re: Syntax for adding suffix to all variable names in a file doesn't work To: [hidden email] A guess: the original variable names are longer than you expected. try something like this untested syntax. compute howlong = length (RTRIM(Var1)). frequencies vars = howlong. Btw, it is often more useful in the long run to use prefixes rather than suffixes. Suggestion to SPSS. It would be a nice feature for the syntax editor if it expanded abbreviations. Art Kendall Social Research Consultants Ruben van den Berg wrote: Dear all, Express yourself instantly with MSN Messenger! MSN Messenger |
| Free forum by Nabble | Edit this page |
