<>
" The question is evidently about string variables that mistakenly were read
in as numeric."
Arina`s initial question sounded more like numeric vars being read in as
strings. And her subject line made -encode- an enticing option... Austin`s
solution can be made shorter to -destring, replace- as the varlist is not
mandatory...
HTH
Martin
-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Nick Cox
Gesendet: Freitag, 13. Februar 2009 13:54
An: [email protected]
Betreff: st: RE: encode question
The question is evidently about string variables that mistakenly were
read in as numeric. Thus -destring-, not -encode-, is the answer. Also,
as Austin's suggestion makes plain, you don't need to code for a loop
over variables or the overwriting of existing variables, as -destring-
will do that for you.
Arina's problem is already written up as two FAQs:
FAQ How can I quickly convert many string variables to numeric
variables?
. . . . . . . . . . . . . . . . . . UCLA Academic Technology
Services
7/08 <http://www.ats.ucla.edu/stat/stata/faq/destring.htm>
FAQ . . . . . . . . . . . . . . . . . . Numeric variables input as
string
2/02 Stata is reading in my variables as string, whereas
they should be numeric. What should I do?
<http://www.stata.com/support/faqs/data/allstring.html>
If you wished to -encode- several variables simultaneously -- and _also_
wanted the same set of value labels -- that is handled by -multencode-
on SSC, as discussed on this list last month.
Nick
[email protected]
Austin Nichols
destring _all, replace
Arina Viseth
I have a dataset that I imported from Excel using insheet. However, many
numerical variables (I have about 200 variables) are now showed as
string variables.
My question is the following: how can I transform each string variable
into numerical one - and also replicate their names - without having to
encode manually each one of them?
*
* 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/