Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: Deleting Characters of a Var Name by index Number


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: Deleting Characters of a Var Name by index Number
Date   Thu, 1 May 2008 21:20:39 +0100

.
If that was the problem, then -renvars, postdrop(1)- is an alternative. 

Sergiy Radyakin

I don't think I understand how you want to transform X42 to X5 based
on your description, but if you'd like to keep two first characters of
the variable names

// begin of file
sysuse auto
ds
local vars `r(varlist)'
foreach var of local vars {
  rename `var' `=substr("`var'",1,2)'
}
// end of file


*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index