Statalist


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

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


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   AW: st: changing the variable name form capital letters to small letters.
Date   Fri, 27 Nov 2009 10:22:36 +0100

<> 

" 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. 


HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Nick Cox
Gesendet: Freitag, 27. November 2009 10:19
An: [email protected]
Betreff: RE: st: changing the variable name form capital letters to small
letters.

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 
[email protected] 

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 [email protected]

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

Rajaram Subramanian Potty <[email protected]>

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
S1Q14
S1Q15
S1Q16
S1Q17
S1Q18
S2Q1
S2Q2
S2Q3
S2Q4
S2Q5
S2Q6
S2Q7
S2Q8
S3Q1
S3Q2
S3Q2CASTE change to s3q2caste
S3Q3
S3Q3OTHER
S3Q4
S3Q5
S3Q6
S3Q6OTHER
S3Q7
S3Q8
S3Q8A
S3Q9
S3Q9DURATION
S3Q10
S3Q10DURATION
S3Q11
S3Q11ILLNESS


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


*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index