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: How can I transfer the variable labels to excel using the outsheet command?


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: How can I transfer the variable labels to excel using the outsheet command?
Date   Thu, 27 May 2010 12:28:16 +0100

This has never been my problem, but I can think of one work-around. 

Assuming the number of observations is at least as great as the number of variables, you could copy the variable labels into a string variable and export that too. 

unab vars : * 
gen varlabel = "" 
local i = 1 

foreach v of local vars { 
	replace varlabel = `"`: var label `v''"' in `i' 
	local ++i 
}

I don't know how you'd reverse that in Excel. You would have a column of variable labels. I understand that Excel users like to have such stuff as a row. 

Nick 
n.j.cox@durham.ac.uk 

A Loumiotis

Yes what I'm actually doing is creating a csv file and i'm using excel
to open it.

But my problem with the variable labels still remain.  My concern is
not with the value labels of a categorical variable (which I know how
to export to a csv file) but with the variable labels of the variable
names.

For example I have used:

label variable var01 "this is variable one"

to create the variable label "this is variable one" for variable var01.

What I want is to export to a csv file not only the variable names but
also the variable labels.



On Thu, May 27, 2010 at 1:39 PM, Neil Shephard <nshephard@gmail.com> wrote:
> On Thu, May 27, 2010 at 10:27 AM, A Loumiotis
> <antonis.loumiotis@gmail.com> wrote:
>> Dear Statalist,
>>
>> When I use the outsheet command the variable names but not the
>> variable labels are transferred to excel.
>> Is there any way to also transfer the variable labels to excel?
>
> As per the Statalist FAQ, it would be useful if you provided the
> _exact_ command you are using.
>
>
> 1. -outsheet- does not have the capacity to write Excel files.  I
> suspect you are writing to a CSV (Comma Separate Variables) file and
> on your OS (I'll hazard a guess at some M$-Windows variant) this file
> extension is associated with M$-Excel so that when double-clicked on
> it opens up in that program.
>
> 2. The -outsheet- command should be default write out variables that
> have labels applied to them using the labels themselves, unless you
> have explicitly specified the -nolabel- option (as explained in -man
> outsheet-).
>
> So, without knowing what you are doing I suspect you mistakenly using
> the -outsheet using filename.csv, comma nolabel- (or similar) syntax,
> and if you omit the -nolabel- option you should obtain what you are
> after.
>
> Neil
>
> --
> "... no scientific worker has a fixed level of significance at which
> from year to year, and in all circumstances, he rejects hypotheses; he
> rather gives his mind to each particular case in the light of his
> evidence and his ideas." - Sir Ronald A. Fisher (1956)
>
> Email - nshephard@gmail.com
> Website - http://slack.ser.man.ac.uk/
> Photos - http://www.flickr.com/photos/slackline/
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/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/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/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index