Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: complete data import


From   Douglas Levy <[email protected]>
To   [email protected]
Subject   Re: st: complete data import
Date   Wed, 23 Apr 2014 16:21:59 -0400

Thanks, Brendan (and Sarah), this seems to work. -Doug

On Wed, Apr 9, 2014 at 4:59 PM, Brendan Halpin <[email protected]> wrote:
> Read each line as a string.
> Create an ID variable that starts at 1 and increments the line after
> each TND line.
> Append the ID as a comma separated string at the end of each line.
> Write out three text files, one for MEM, one for ITM and one for TND.
> Read them with insheet, save as .dta files.
> Merge as appropriate on the ID variable.
>
>
> Approximately:
> Create slug.dct containing this line:
>
> dictionary using raw.csv { str244 slug }
>
> . infile using slug.dct
> . gen id = 1
> . replace id = id[_n-1] + regexm(slug[_n-1], "^TND") if _n>1
> . replace slug = string(id) + "," + slug
> . outfile slug using mem.csv if regexm(slug, ",MEM,"), wide
> . outfile slug using itm.csv if regexm(slug, ",ITM,"), wide
> . outfile slug using tnd.csv if regexm(slug, ",TND,"), wide
>
> Now you have 3 comma-separated-value files, readable by insheet, that
> have an ID variable on which you can merge.
>
> Brendan
> --
> Brendan Halpin, Head, Department of Sociology, University of Limerick, Ireland
> Tel: w +353-61-213147  f +353-61-202569  h +353-61-338562;  Room F1-002 x 3147
> mailto:[email protected]    ULSociology on Facebook: http://on.fb.me/fjIK9t
> http://teaching.sociology.ul.ie/bhalpin/wordpress         twitter:@ULSociology
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/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/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index