Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: st: changing the variable name form capital letters to small letters.


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: changing the variable name form capital letters to small letters.
Date   Fri, 27 Nov 2009 09:37:04 -0000

Equally, knowing the solution from first principles is also always
worthwhile. 

Nick 
n.j.cox@durham.ac.uk 

Martin Weiss

" I can't think of any good reason not to use -renvars-"


Neither can I: I did not want to imply that -renvars- is not a good
command,
just to set the record straight re -replace- and show how you can
achieve
the same result from first principles. 

Nick Cox

What's more, as well as doing completely the wrong thing the -replace-
call here would be illegal unless the variable in question were a string
variable. 

I can't think of any good reason not to use -renvars- when 

renvars, lower 

is a complete solution to the problem named. 

Nick 
n.j.cox@durham.ac.uk 

Martin Weiss

-replace- would change the values of the variable, not its name. If
Rajaram
does not want to use -renvars-, as suggested by Richard, he can of
course
say

foreach var of varlist _all{
	rename `var' `=lower("`var'")'
}

" some of them are numeric and some are string variables."

The storage type of the variables should have no bearing on this
operation,
as all you want to change is the name, not the values. If ever you
wanted to
condition on the type, use -ds-, as in my
http://www.stata-journal.com/article.html?article=dm0040


Rose gjhxmu@sina.com

Suppose the variable is named x,  try "replace x=lower(x)".

Rajaram Subramanian Potty <rajara999@gmail.com>

Is there any way I can change the name of the variable. In my data set
the variables are in capital letters and I want them to change into
small letters. There are about 700 variables and I wanted to change
them into small letters. The list of some of the variables in my data
set is given below, some of them are numeric and some are string
variables.

S1Q1 wanted to change to s1q1
S1Q2 change to s1q2
S1Q3 change to s1q3
S1Q4 change to s1q4 etc.
S1Q5
S1Q6
S1Q7
S1Q8
S1Q9
S1Q10
S1Q11
S1Q12
S1Q13

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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