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
Sergiy Radyakin <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: complete data import
Date
Mon, 7 Apr 2014 20:44:32 -0400
where record types are not numeric but strings "ITM" "TND" and "MEM",
but the fact that it is a CSV means, perhaps, that someone has already
played with this file, since in all the CSPro files I've seen so far
the storage was positional. Perhaps you can find the raw file
somewhere upstream, then employ
-usecspro- to read it in:
http://ideas.repec.org/p/boc/usug13/17.html
(slide #9 illustrates the dataset layout of CSPro that is remarkably similar).
Hope this helps.
Best, Sergiy Radyakin
On Mon, Apr 7, 2014 at 3:45 PM, Douglas Levy
<[email protected]> wrote:
> Hi All,
> I have a complicated .csv file that I'm trying to import and I'm
> hoping you can provide some guidance on the best strategy. See the
> example below. Each record in the file consists of up to 3 line types
> labeled "MEM", "ITM", and "TND". Each line type has a particular
> format. For example, "MEM" line types have var1, var2, and var3. "ITM"
> has var4, var5, and var6. Etc. Each record may or may not have a "MEM"
> line, has 1 or more "ITM" lines, and has 1 "TND" line that ends the
> record. A record is defined as ending with the "TND" line. The "MEM"
> line may come at any point in the record, but is often first.
>
> Example data
> ITM,S,0,1,1.35,5100001261,soup,
> TND,N,0,0,0,1.35,0,0
> ITM,S,0,1,1.35,5100001261,soup,
> TND,N,0,0,0,1.35,0,0
> MEM,N,280211400001,,,,,
> ITM,S,0,1,1.35,5100001261,soup,
> TND,N,0,0,0,0,11.28,0
> ITM,S,0,1,1.29,5000001011,milk,
> TND,N,0,0,0,1.29,0,0
> MEM,N,280211400159,,,,,
> ITM,S,0,1,1.29,5000001011,milk,
> ITM,S,0,1,1.29,5000001011,milk,
> ITM,S,0,1,1.29,5000001011,milk,
> TND,N,4,0,0,0,0,0
>
> I'd like to attach a unique record identifier the "TND" line and I'd
> like to attach the "TND" and "MEM" info for a given record to each
> "ITM" line in the record. Ultimately, I'd like the Stata file for the
> above data to look like this, where the number after "soup" or "milk"
> is the record identifier (placement of that variable is not
> important):
> ITM,S,0,1,1.35,5100001261,soup, 1, TND,N,0,0,0,1.35,0,0
> ITM,S,0,1,1.35,5100001261,soup, 2, TND,N,0,0,0,1.35,0,0
> ITM,S,0,1,1.35,5100001261,soup, 3, TND,N,0,0,0,0,11.28,0,
> MEM,N,280211400001,,,,,
> ITM,S,0,1,1.29,5000001011,milk, 4, TND,N,0,0,0,1.29,0,0
> ITM,S,0,1,1.29,5000001011,milk, 5, TND,N,4,0,0,0,0,0, MEM,N,280211400159,,,,,
> ITM,S,0,1,1.29,5000001011,milk, 5, TND,N,4,0,0,0,0,0, MEM,N,280211400159,,,,,
> ITM,S,0,1,1.29,5000001011,milk, 5, TND,N,4,0,0,0,0,0, MEM,N,280211400159,,,,,
>
> Any advice would be most welcome!
> Best,
> Doug
> *
> * 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/