Statalist


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

st: Re: Text to column in Stata


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Re: Text to column in Stata
Date   Tue, 24 Mar 2009 22:35:15 +0100

<>

****
clear*
inp str5 var1 str5 var2
A112 B112
A222 B222
A344 B344
end

gen mynewvar1=substr(var1,1,1)
gen mynewvar2=substr(var2,1,1)
list
*****


HTH
Martin
_______________________
----- Original Message ----- From: "Tomas M" <anon556656@live.ca>
To: <statalist@hsphsun2.harvard.edu>
Sent: Tuesday, March 24, 2009 10:29 PM
Subject: st: Text to column in Stata


Hello all,

I have a string variable, say "A###" (i.e. A112, A222, A344, etc.).

How would I code in Stata to generate a new variable that includes only the "A"?

In summary, I have a variable, "A###", and I want to generate a new variable, "A".

Similarly, I have a variable, "B###", and I want to generate a new variable, "B".


Any ideas on how I can do this in Stata?

In Excel, I would just use text to columns, and break it down into two separate columns. Anything like this in Stata?

Thank you!


_________________________________________________________________
Share photos with friends on Windows Live Messenger
http://go.microsoft.com/?linkid=9650734
*
*   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   |   What's new   |   Site index