Bookmark and Share

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]

st: Shortening variable names loop problem


From   George Murray <[email protected]>
To   [email protected]
Subject   st: Shortening variable names loop problem
Date   Thu, 19 Sep 2013 17:39:49 +1000

Dear Statalist,

I am trying to shorten all variables with 31 or 32 characters to 30 by
removing the last 1 or 2 characters. Does any one know why the
following command does not work (type mismatch):

foreach var of varlist * {
replace `var' = "substr("`var'",1,30)"'
}

Replacing the second line with -rename `var' "substr("`var'",1,30)"-
also doesn't work (parenthesis unbalanced).

Does anyone have a solution?

Thanks.
*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index