[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Re: encode question

From   "Martin Weiss" <>
To   <>
Subject   st: Re: encode question
Date   Thu, 12 Feb 2009 21:23:34 +0100

Try this with your data, but make backups to guard against any nasty surprises along the way. The auto dataset has only one string, so this example looks stupid - but isn`t...

sysuse auto, clear
qui ds, has(type string)
foreach var of varlist `r(varlist)'{
encode `var', gen(`var'new)
drop `var'
rename `var'new `var'

----- Original Message ----- From: "Arina Viseth" <arina@UDel.Edu>
To: <>
Sent: Thursday, February 12, 2009 9:17 PM
Subject: st: encode question

Dear all,

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?

Thank you very much in advance for any help, I would very much appreciate it.


*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index