Bookmark and Share

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

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

Re: st: complete data import

From   Brendan Halpin <[email protected]>
To   Douglas Levy <[email protected]>
Subject   Re: st: complete data import
Date   Wed, 9 Apr 2014 21:59:41 +0100

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.

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 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:         twitter:@ULSociology
*   For searches and help try:

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