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

st: RE: How to rename these variables?


From   "Wallace, John" <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: RE: How to rename these variables?
Date   Mon, 20 Oct 2003 14:31:26 -0700

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.

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