I have a dataset that contains 100 contiguous variables named c1 to
c100. What's the most efficient syntax for changing the names (not the labels) of those variables to Brand1 to Brand100? I also want to delete some variables via syntax. How would I do that? Thanks for your help. |
Jim,
since u have them in sequence, this should do the trick: ren vars (c1 TO c100=brand1 to brand100). exe. deletting is best done using /DROP while saving out the datafile. HTH, Vivek -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of Jim Moffitt Sent: Friday, August 18, 2006 2:50 To: [hidden email] Subject: Changing Variable Names and Deleting Variables Via Syntax I have a dataset that contains 100 contiguous variables named c1 to c100. What's the most efficient syntax for changing the names (not the labels) of those variables to Brand1 to Brand100? I also want to delete some variables via syntax. How would I do that? Thanks for your help. |
In reply to this post by Jim Moffitt
Unfortunately, you cannot use the keyword TO in the RENAME statement (at
least up to v.13, if I'm not mistaken). RENAME VARIABLES (oldvar1 oldvar2 ... oldvarn = newvar1 newvar2 ... newvarn). DELETE VARIABLES var1 var2 ... . EXECUTE. Good luck. Dominic Lusinchi Statistician Far West Research Statistical Consulting San Francisco, California 415-664-3032 www.farwestresearch.com -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Jim Moffitt Sent: Friday, August 18, 2006 11:50 AM To: [hidden email] Subject: Changing Variable Names and Deleting Variables Via Syntax I have a dataset that contains 100 contiguous variables named c1 to c100. What's the most efficient syntax for changing the names (not the labels) of those variables to Brand1 to Brand100? I also want to delete some variables via syntax. How would I do that? Thanks for your help. |
In reply to this post by Jim Moffitt
You can delete the variables by syntax as
DELETE VARIABLE var1 var2. Siraj -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Vivek Kurup Sent: Friday, August 18, 2006 3:02 PM To: [hidden email] Subject: Re: Changing Variable Names and Deleting Variables Via Syntax Jim, since u have them in sequence, this should do the trick: ren vars (c1 TO c100=brand1 to brand100). exe. deletting is best done using /DROP while saving out the datafile. HTH, Vivek -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of Jim Moffitt Sent: Friday, August 18, 2006 2:50 To: [hidden email] Subject: Changing Variable Names and Deleting Variables Via Syntax I have a dataset that contains 100 contiguous variables named c1 to c100. What's the most efficient syntax for changing the names (not the labels) of those variables to Brand1 to Brand100? I also want to delete some variables via syntax. How would I do that? Thanks for your help. |
Dear friend
Use this macro for solve your problem: DEFINE RENAMELIST (SIMBOL1=!TOKENS(1)/ SIMBOL2=!TOKENS(1)) !DO !FILE= 1 !TO 100. RENAME VARIABLES (!CONCAT(!SIMBOL1,!FILE)=!CONCAT(!SIMBOL2, !FILE)). !DOEND. !ENDDEFINE. RENAMELIST SIMBOL1=C SIMBOL2=BRAD. To delete variables use DELETE VARIABLES = variables list. Carlos Renato - Statistician ([hidden email]) 2006/8/18, Siraj Ur-rehman <[hidden email]>: > > You can delete the variables by syntax as > > DELETE VARIABLE var1 var2. > > Siraj > > -----Original Message----- > From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of > Vivek Kurup > Sent: Friday, August 18, 2006 3:02 PM > To: [hidden email] > Subject: Re: Changing Variable Names and Deleting Variables Via Syntax > > Jim, > > since u have them in sequence, this should do the trick: > > ren vars (c1 TO c100=brand1 to brand100). > exe. > > deletting is best done using /DROP while saving out the datafile. > > HTH, > Vivek > > > -----Original Message----- > From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of > Jim Moffitt > Sent: Friday, August 18, 2006 2:50 > To: [hidden email] > Subject: Changing Variable Names and Deleting Variables Via Syntax > > > I have a dataset that contains 100 contiguous variables named c1 to > c100. > > What's the most efficient syntax for changing the names (not the labels) > of those variables to Brand1 to Brand100? > > I also want to delete some variables via syntax. > > How would I do that? > > Thanks for your help. > -- Carlos Renato [hidden email] |
In reply to this post by Jim Moffitt
Dear friend
Use this macro for solve your problem: DEFINE RENAMELIST (SIMBOL1=!TOKENS(1)/ SIMBOL2=!TOKENS(1)) !DO !FILE= 1 !TO 100. RENAME VARIABLES (!CONCAT(!SIMBOL1,!FILE)=!CONCAT(!SIMBOL2, !FILE)). !DOEND. !ENDDEFINE. RENAMELIST SIMBOL1=C SIMBOL2=BRAD. To delete variables use DELETE VARIABLES = variables list. Carlos Renato - Statistician ([hidden email]) ********************************************************************************* 2006/8/18, Jim Moffitt <[hidden email]>: > > I have a dataset that contains 100 contiguous variables named c1 to > c100. > > What's the most efficient syntax for changing the names (not the labels) > of those variables to Brand1 to Brand100? > > I also want to delete some variables via syntax. > > How would I do that? > > Thanks for your help. > -- Carlos Renato [hidden email] |
In reply to this post by Jim Moffitt
Thanks to Carlos, Dominic, Siraj and Vivek for your help. All of your
solutions seem to do the trick! -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Carlos Renato Sent: Friday, August 18, 2006 2:38 PM To: [hidden email] Subject: Re: Changing Variable Names and Deleting Variables Via Syntax Dear friend Use this macro for solve your problem: DEFINE RENAMELIST (SIMBOL1=!TOKENS(1)/ SIMBOL2=!TOKENS(1)) !DO !FILE= 1 !TO 100. RENAME VARIABLES (!CONCAT(!SIMBOL1,!FILE)=!CONCAT(!SIMBOL2, !FILE)). !DOEND. !ENDDEFINE. RENAMELIST SIMBOL1=C SIMBOL2=BRAD. To delete variables use DELETE VARIABLES = variables list. Carlos Renato - Statistician ([hidden email]) 2006/8/18, Siraj Ur-rehman <[hidden email]>: > > You can delete the variables by syntax as > > DELETE VARIABLE var1 var2. > > Siraj > > -----Original Message----- > From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf > Of Vivek Kurup > Sent: Friday, August 18, 2006 3:02 PM > To: [hidden email] > Subject: Re: Changing Variable Names and Deleting Variables Via Syntax > > Jim, > > since u have them in sequence, this should do the trick: > > ren vars (c1 TO c100=brand1 to brand100). > exe. > > deletting is best done using /DROP while saving out the datafile. > > HTH, > Vivek > > > -----Original Message----- > From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf > Of Jim Moffitt > Sent: Friday, August 18, 2006 2:50 > To: [hidden email] > Subject: Changing Variable Names and Deleting Variables Via Syntax > > > I have a dataset that contains 100 contiguous variables named c1 to > c100. > > What's the most efficient syntax for changing the names (not the > labels) of those variables to Brand1 to Brand100? > > I also want to delete some variables via syntax. > > How would I do that? > > Thanks for your help. > -- Carlos Renato [hidden email] |
In reply to this post by Jim Moffitt
On Fri, 18 Aug 2006 13:50:08 -0500, Jim Moffitt <[hidden email]>
wrote: >I have a dataset that contains 100 contiguous variables named c1 to >c100. > >What's the most efficient syntax for changing the names (not the labels) >of those variables to Brand1 to Brand100? > >I also want to delete some variables via syntax. > >How would I do that? > >Thanks for your help. DO REPEAT ORIGIN = C1 TO C100 / TARGET = BRAND1 TO BRAND100 . RECODE ORIGIN (ELSE=COPY) INTO TARGET . END REPEAT . EXECUTE . SAVE OUTFILE='C:\TEMP\FILEN.SAV' /DROP = VAR1 TO VAR100 /COMPRESSED. The "/DROP = var" statement can be used to drop other variables as well before the file is saved, users can build in the drop variable command there. |
Free forum by Nabble | Edit this page |