Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Rename all?
From 
 
"William Gould, StataCorp LP" <[email protected]> 
To 
 
[email protected] 
Subject 
 
Re: st: Rename all? 
Date 
 
Wed, 07 Nov 2012 14:10:06 -0600 
Zhangqunzi <[email protected]> wrote, 
> I am trying to rename a current varlist prc1...10 into shrout1....10.
> 
> I tried 
> 
>      . rename prc* shrout* 
> 
> But it doesn't work, what command should I use then?
Evidently Zhangqunzi is not using Stata 12.  I just want to show the
rest of you that typing -rename prc* shrout*- will work if you have
Stata 12:
    . describe
    Contains data from ds.dta
      obs:             1                          
     vars:            13                      7 Nov 2012 13:50
     size:            52                          
    ----------------------------------------------------------
                  storage  display   value
    variable name   type   format    label      variable label
    ----------------------------------------------------------
    alpha           float  %9.0g                  
    prc1            float  %9.0g                  
    prc2            float  %9.0g                  
    prc3            float  %9.0g                  
    prc4            float  %9.0g                  
    prc5            float  %9.0g                  
    prc6            float  %9.0g                  
    prc7            float  %9.0g                  
    prc8            float  %9.0g                  
    prc9            float  %9.0g                  
    prc10           float  %9.0g                  
    new1            float  %9.0g                  
    new             float  %9.0g                  
    ----------------------------------------------------------
    Sorted by:  
    . rename prc* shrout*
    . describe
    Contains data from ds.dta
      obs:             1                          
     vars:            13                      7 Nov 2012 13:50
     size:            52                          
    ----------------------------------------------------------
                  storage  display   value
    variable name   type   format    label      variable label
    ----------------------------------------------------------
    alpha           float  %9.0g                  
    shrout1         float  %9.0g                  
    shrout2         float  %9.0g                  
    shrout3         float  %9.0g                  
    shrout4         float  %9.0g                  
    shrout5         float  %9.0g                  
    shrout6         float  %9.0g                  
    shrout7         float  %9.0g                  
    shrout8         float  %9.0g                  
    shrout9         float  %9.0g                  
    shrout10        float  %9.0g                  
    new1            float  %9.0g                  
    new             float  %9.0g                  
    ----------------------------------------------------------
    Sorted by:  
         Note:  dataset has changed since last saved
Actually, it might be better to type 
	. rename prc# shrout#
if you also had a variable named prctotal and didn't want it 
renamed to shrouttotal.
Remember the -dryrun- option.  That allows you to check what 
-rename- would do before giving the command for real:
Below I consider the idea of renaming the variable back:
    . rename shrout# prc#, dryrun
       oldname | newname
      ---------+---------
       shrout1 | prc1
       shrout2 | prc2
       shrout3 | prc3
       shrout4 | prc4
       shrout5 | prc5
       shrout6 | prc6
       shrout7 | prc7
       shrout8 | prc8
       shrout9 | prc9
      shrout10 | prc10
      -------------------
I considered the idea; the -dryrun- option prevented the changes from 
being made.
-- Bill
[email protected]
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/