Statalist


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

st: Re:Reading data into Stata


From   Paul Seed <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: Re:Reading data into Stata
Date   Fri, 10 Oct 2008 16:25:28 +0100

What Victor wants can be accomplished by:

* Input data 2 composite string variables, broken at the comma
   insheet var1 var2 using myfile.csv, comma clear

* Break up the first string at the spaces
   gen string1 = word(var1,1)
   gen string2 = word(var1,2)
* Note: string2 will have some missing values

* Break up the second string at the spaces
   gen string3= word(var2,1)
   gen n1= word(var2,2)
   gen n2= word(var2,3)
   destring n1 n2, replace

* Drop the spare variables
   drop var1 var2

HTH

Paul


Fra: [email protected] [[email protected]] p&#229; vegne av Victor M. Zammit [[email protected]]
> > Sendt: 9. oktober 2008 22:01
> > Til: [email protected]
> > Emne: st: Re:Reading  data into Stata
> >
> > 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
> >
> >

Paul T Seed MSc CStat, Lecturer in Medical Statistics,
tel  (+44) (0) 20 7188 3642, fax (+44) (0) 20 7620 1227
Wednesdays: (+4) (0) 20 7848 4148

[email protected], [email protected]

King's College London, Division of Reproduction and Endocrinology
St Thomas' Hospital, Westminster Bridge Road, London SE1 7EH



*
*   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