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

st: How to rename these variables?


From   John Hennen <[email protected]>
To   [email protected]
Subject   st: How to rename these variables?
Date   Sat, 18 Oct 2003 16:05:27 -0400

[email protected] wrote:

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

RESPONSE:
Assuming that you have 3 sets of the form
v1_1  v2_1  v3_1  v1_2  v2_2  v3_2  v1_3  v2_3  v3_3
How about something like this:

 foreach X in v1 v2 v3 {
   foreach Y of num 1/3 {
   rename `X'_`Y'  `X'_0`Y'
    }
    }

John Hennen
Boston




Any information, including protected health information (PHI), transmitted
in this email is intended only for the person or entity to which it is
addressed and may contain information that is privileged, confidential and or
exempt from disclosure under applicable Federal or State law. Any review,
retransmission, dissemination or other use of or taking of any action in
reliance upon, protected health information (PHI) by persons or entities other
than the intended recipient is prohibited. If you received this email in error,
please contact the sender and delete the material from any computer.



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index