Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Sergiy Radyakin <serjradyakin@gmail.com> |
To | "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |
Subject | Re: st: RE: outsheeting tempvar names |
Date | Wed, 18 Sep 2013 12:33:30 -0400 |
On Wed, Sep 18, 2013 at 11:07 AM, Joe Canner <jcanner1@jhmi.edu> wrote: > Adrian, > > A couple of possibilities, one of which may be more helpful than the other, depending on the context: > > 1) Rename the temporary variables first: > . rename `var1' var1 > . outsheet var1 using "path" > > 2) Add a label to the temporary variables and use -export excel-, which allows you to use the variable label as the column header: > . label var `var1' "var1" > . export excel `var1' using "path", first(varl) > > Regards, > Joe Canner > Johns Hopkins University School of Medicine > > -----Original Message----- > From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of adrien bouguen > Sent: Wednesday, September 18, 2013 10:52 AM > To: statalist@hsphsun2.harvard.edu > Subject: st: outsheeting tempvar names > > Dear statalisters, > > I would like to extract in a excel sheet few temporary variables using outsheet. My problem is when I do for instance: > > outsheet `var1' using "path" > > the variable name in the excel sheet is not var1 but something like __00000. It is annoying because I'd like to use Adrien, this is correct, because from the exporter's point of view the variable __00000 is just like any other variable, it doesn't know that it is temporary, and it exports it with a variable name as-is. To complicate matters, there may be not one but several pointers to the same tempvar: tempvar var1 local income `var1' Now both `var1' and `income' refer to the same variable. There is no way to determine which name is desired during export, but the export doesn't even suspect that this is the case, it just takes the variable name and is completely ignorant of any pointers to it (regardless whether it is outsheet or export excel). Joe has shown you two possible solutions to your problem. Be careful with the first one, since renaming a temporary variable will make it 'not-temporary' (in a sense it will no longer be dropped on completion of your routine). If you are intending to produce Excel output in the end, I'd support the second suggestion with the labels. It seems natural to have a facility IsTempVar(varname) = {0|1}, but it gets complicated, since the variable may be not temporary in the current context, but be temporary in the outer context. I'd find some use for it e.g. in the procedures that are sometimes getting surprised by additional variables added by -sortpreserve- : do http://radyakin.org/statalist/2013091801/foobar.do Standard -outsheet- could benefit from the same behavior as -export excel-, specifically from writing variable labels instead of variable names. Best, Sergiy >this as a regression table with var1 as column name. > > Any idea how to solve this? > > Thank you so much for your replies > > Best > > > -- > Adrien Bouguen > Ecole d'économie de Paris - J-PAL > 66 bis avenue Jean Moulin > 75014 Paris > tel: +33 (0)1 71 19 40 83 > port: +33 (0)6 69 34 12 02 > > * > * 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/ * * 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/