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: output variables and labels to excel


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: output variables and labels to excel
Date   Mon, 19 Aug 2013 19:04:47 +0100

You could do something like this assuming that you don't have more
variables than observations.

gen varname = ""
gen varlabel = ""
local i = 1
quietly foreach v of var * {
     replace varname = "`v'" in `i'
     replace varlabel = "`: var label `v''" in `i'
     local ++i
}

and then export those two variables. But Roger Newson's  -descsave- is
much more versatile and elaborate. -search descsave- for locations.



Nick
[email protected]


On 19 August 2013 18:39, Caroline Wilson <[email protected]> wrote:
> Hi Stata,
>
> I'm trying to output the names of all variables in my Stata dataset and their labels to an excel file. For example, I would like to end product to look like this:
>
> Variable name     Variable label
> gender            Patient gender
> DOB               Date of birth
> Race              Patient race
> etc.
>
> Is there an easy way to do this? I tried codebook but it gave me a lot more information than I needed, and I also had formatting problems when copying and pasting the output into Excel.
>
> Many thanks in advance for any help!
> Caroline
> *
> *   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