Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: saving .dta files with codes replacing numbers


From   Joseph Coveney <jcoveney@bigplanet.com>
To   Statalist <statalist@hsphsun2.harvard.edu>
Subject   Re: st: saving .dta files with codes replacing numbers
Date   Thu, 12 Jan 2006 16:59:51 +0900

Wolfgang Polasek wrote:

When I save the data for exporting it into Excel I get the numerical
codes and not the string variables as I see them in the data editor.

What should I do to get the the string variables in a spread sheet?

--------------------------------------------------------------------------------

Wouldn't the -label- option to -outsheet- do this?

Joseph Coveney


. clear

. set more off

. set obs 10
obs was 0, now 10

. tempfile tmpfil0

. generate str1 original = char(64 + _n)

. encode original, generate(encoded)

. list, nolabel noobs clean

   original   encoded
          A         1
          B         2
          C         3
          D         4
          E         5
          F         6
          G         7
          H         8
          I         9
          J        10

. outsheet using `tmpfil0', label // <-- Here

. insheet using `tmpfil0', names clear
(2 vars, 10 obs)

. list, nolabel noobs clean

   original   encoded
          A         A
          B         B
          C         C
          D         D
          E         E
          F         F
          G         G
          H         H
          I         I
          J         J

. erase `tmpfil0'

. exit

end of do-file

*
*   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–2021 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index