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]
st: RE: output variables and labels to excel
From
"Radwin, David" <[email protected]>
To
<[email protected]>
Subject
st: RE: output variables and labels to excel
Date
Mon, 19 Aug 2013 14:04:30 -0400
Caroline,
Here is an example. `=char(9)' represents the tab character and separates the variable name from the variable label.
****************************************************
sysuse auto, clear
tempname fh
file open `fh' using "myfile.txt", write replace
file write `fh' "Variable name`=char(9)'Variable label" _newline
foreach v of varlist * {
file write `fh' "`v'`=char(9)'`: variable label `v''" _newline
}
file close `fh'
type myfile.txt
****************************************************
David
--
David Radwin
Senior Research Associate
Education Studies Division
RTI International
2150 Shattuck Ave., Suite 800
Berkeley, CA 94704
Phone: 510-665-8274
www.rti.org
> -----Original Message-----
> From: [email protected] [mailto:owner-
> [email protected]] On Behalf Of Caroline Wilson
> Sent: Monday, August 19, 2013 10:40 AM
> To: [email protected]
> Subject: st: output variables and labels to excel
>
> 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/