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

st: How to rename these variables?


From   [email protected]
To   [email protected]
Subject   st: How to rename these variables?
Date   Sat, 18 Oct 2003 14:47:16 -0400

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.

Best.





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