Statalist


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

Re: st: Re:Reading data into Stata


From   "Gabi Huiber" <[email protected]>
To   [email protected]
Subject   Re: st: Re:Reading data into Stata
Date   Thu, 9 Oct 2008 21:16:21 -0400

I would read it in with insheet as a comma-delimited text file. This
will combine the variables after the comma into one string variable,
but that's OK.

You split with:

split var2, gen(stub)
drop var2

and then you recover your numeric variables:

destring stub2, replace
destring stub3, replace

This assumes that the string variable that comes right after the comma
has no spaces in it. If it does, then split will produce more than 3
stubs. There are things you can do in that case too, but they would
qualify as a bit of work.

Gabi

On Thu, Oct 9, 2008 at 4:01 PM, Victor M. Zammit <[email protected]> wrote:
> Dear Statalist,
>
> I need to read into Stata,data that has a comma ,sometimes after one string
> variable and sometimes after two,string variables.And after
>
> the comma,one string variable and two numeric variables.,always.The raw list
> of data is thousands of rows long.Is there a  way I could
>
> get this raw data into Stata without too much work ? I thank you for any
> help you can give me.
>
> string , string numeric numeric
>
> string string , string numeric numeric
>
> string string , string numeric numeric
>
> string string , string numeric numeric
>
> string , string numeric numeric
>
> string string , string numeric numeric
>
> Victor Michael Zammit
>
> *
> *   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index