Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: Using variable label in stata as you would a macro


From   Martin Weiss <[email protected]>
To   [email protected]
Subject   st: Re: Using variable label in stata as you would a macro
Date   Mon, 26 May 2008 23:53:04 +0200

************
loc varlab: var l `var'
************
puts the label in local varlab...

Martin Weiss
_______________________
----- Original Message ----- 
From: "Conner Mullally" <[email protected]>
To: <[email protected]>
Sent: Monday, May 26, 2008 11:38 PM
Subject: st: Using variable label in stata as you would a macro


> Hello all,
> I am wondering if there is a way in stata to use the labels
> given to variables as you might a macro.  For example,
> suppose you have a variable "state" where the values are the
> state names in the US.  You turn this into a series of dummy
> variables then run a series of regressions in a loop such
> as:
> foreach var of varlist _Istate_1-_Istate_50 {
> reg x y
> outreg if `var'==1, se append
> }
> What I'm wondering if there is a way to do this:
> foreach var of varlist _Istate_1-_Istate_50 {
> reg x y
> (some command that gives you the variable label of `var')
> outreg if `var'==1, se append ctitle(label of `var')
> }
> This would give you a spreadsheet where each column is
> labeled with the relevant state name. 
> 
> Any thoughts?  Thanks in advance.
> 
> 
> 
> 
> 
> 
> **********************************************************
> Conner Mullally
> Ph.D. Candidate
> Department of Agricultural and Resource Economics
> University of California, Davis
> office:                   530 752 1048
> cell:                      530 902 7484
> cell: (Lima):          001 511 989813181
> email and Skype: [email protected]
> 
> **********************************************************
> Conner Mullally
> Ph.D. Candidate
> Department of Agricultural and Resource Economics
> University of California, Davis
> office:                   530 752 1048
> cell:                      530 902 7484
> cell: (Lima):          001 511 989813181
> email and Skype: [email protected]
> *
> *   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