Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: label wide format variables with same label for different years


From   Nick Cox <njcoxstata@gmail.com>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: label wide format variables with same label for different years
Date   Tue, 18 Jun 2013 11:58:27 +0100

This seems most unlikely to be a good idea, as many variables in
graphs and tables would now be labelled identically despite different
meanings. The more general problem is that this data structure (I
won't sign up to the word "format" here) is poor for the majority of
panel or longitudinal problems. A -reshape- is strongly advisable.

I am reluctant to hand you a loaded gun, but what you want is

foreach v of var income_* {
      label var `v' "income"
}

Nick
njcoxstata@gmail.com


On 18 June 2013 11:52,  <I.Roland@lse.ac.uk> wrote:
> Dear Statalisters,
>
> My data is in wide format and I would like to give the same label to several variables in different years.
>
> Example:
>
> income_2013       income_2012
> 10                             8
>
> I want to label both income_2013 and income_2012 as "income". Since I have many years, I am looking for a way of doing this with one command line instead of
>
> label variable income_2013 "income"
> label variable income_2012 "income"
>
> I intuitively tried
>
> label variable income_* "income" but this does not work, and I could not find an answer online.
>
> Thank you for your help with this!
> Isa
>
> Please access the attached hyperlink for an important electronic communications disclaimer: http://lse.ac.uk/emailDisclaimer
>
> *
> *   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index