Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

RE: st: loop in variables labels


From   Haluk Vahaboglu <[email protected]>
To   "[email protected]" <[email protected]>
Subject   RE: st: loop in variables labels
Date   Mon, 15 Jul 2013 23:33:27 +0000

Nick thank you for the code and for your critical explanations on "how to use this environment".
I also want to thank to Sergy for the code which is also working.

I am trying to upgrade to stata from excel totally. Automation (batch applications) in the initial validation and reshaping of the raw data in stata is a great deal. Thanks again.

Prof. Dr. Haluk Vahaboğlu
Istanbul Medeniyet
Üniversitesi,
Göztepe Eğitim ve Araştırma Hastanesi
Enfeksiyon Hastalıkları
ve Klinik Mikrobiyoloji ABD
Dr. Erkin Caddesi 34730
Kadıköy / Istanbul TURKIYE




----------------------------------------
> Date: Mon, 15 Jul 2013 22:31:28 +0100
> Subject: Re: st: loop in variables labels
> From: [email protected]
> To: [email protected]
>
> This thread has already proved confusing given that the problem
> description changed from this initial statement. That has led to some
> very complicated code being suggested.
>
> In addition, Haluk is not acting as recommended:
>
> 1. This thread was started by replying to a different thread, so
> threading in the archives is messed up. As the FAQ indicates, you
> should start a new thread with a new posting.
>
> 2. The heading here refers to variable labels, but the problem appears
> to be about variable names.
>
> 3. The implication is that searching started with the FAQs or the
> internet. Searching should generally start with -help- and the
> manuals.
>
> The irregularity in variable names implies that such irregularity
> might be better ignored altogether. It appears that they keywords such
> as "DAYS" and the numbers such as "3" are the only crucial elements.
> That leads to this code sketch:
>
> foreach v of var * {
> local V : subinstr local v "_" " ", all
> tokenize `V'
> rename `v' `2'_`1'
> }
>
> If all underscores are replaced with blanks, what is left can be
> parsed into tokens. The wanted names appear to be the second token, an
> underscore and the first token.
>
> Nick
> [email protected]
>
>
> On 15 July 2013 12:35, Haluk Vahaboglu <[email protected]> wrote:
>> Dear listers,
>>
>> I have some a *.dta file that is imported from an *.xls with some 30 variables named as _3_DAYS_X_X; _6_DAYS_X_X; _9_DAYS_X_X;_3_WEEKS_X_X; _6_WEEKS_X_X; _9_WEEKS_X_X and so on.
>> I want to rename all these var names using a foreach loop to DAYS_3; DAYS_6...;WEEKS_3... and so on.
>> I could not find a help in FAQ or internet search.
>> I would appreciate any help
>>
>> Regards
>>
>> Prof. Dr. Haluk Vahaboğlu
>> Istanbul Medeniyet
>> Üniversitesi,
>> Göztepe Eğitim ve Araştırma Hastanesi
>> Enfeksiyon Hastalıkları
>> ve Klinik Mikrobiyoloji ABD
>> Dr. Erkin Caddesi 34730
>> Kadıköy / Istanbul TURKIYE
>>
>> *
>> * For searches and help try:
>> * http://www.stata.com/help.cgi?search
>> * http://www.stata.com/support/faqs/resources/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/faqs/resources/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/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index