Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: RE: How to rename these variables?


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: How to rename these variables?
Date   Tue, 21 Oct 2003 10:11:39 +0100

Thanks for the plug; but also credit where credit 
is due. Jeroen Weesie is joint author of -renvars-. 

Nick 
[email protected] 

> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]]On Behalf Of 
> Wallace, John
> Sent: 20 October 2003 22:31
> To: '[email protected]'
> Subject: st: RE: How to rename these variables?
> 
> 
> I have recently been using Nick Cox's -renvars- command for 
> similar sorts of
> renaming puzzles.  Try .findit renvars to get an 
> installation module.
> 
> -JW
> 
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] 
> Sent: Saturday, October 18, 2003 11:47 AM
> To: [email protected]
> Subject: st: How to rename these variables?
> 
> Dear all,
> 
> I have a set of variables that I want to rename.
> 
> I want to transform these v1_1 v2_1 v1_2 v2_2 etc..
> to v1_01 v2_01 v1_02 v2_02 etc...
> 
> I try the lenght, index, and substr functions. But I do not know
> how to concatenate the results.
> 
> 
> gen l = length("v_01")
> sum l
> gen p = index("v0_1","_")
> sum p
> if ( l - p == 1 ) { di "Difference is 1" }
> gen str4 vr = substr("v0_1",1,3)
> tab vr
> gen str1 vl = substr("v0_1",1,l)
> tab vl
> replace vl = substr("v0_1",l,1)
> tab vl
> 
> Is there any way to do this? Stata7 seems not to understand 
> the concat()
> function.
> 

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