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: Using infile with varying lines() per observation
From
Kevin McConeghy <[email protected]>
To
[email protected]
Subject
Re: st: Using infile with varying lines() per observation
Date
Fri, 26 Jul 2013 15:18:18 -0500
Thank you for your help Sergiy, however I did a bad job describing my
data. I am having trouble adapting your code. The columns are
fixed-format.
The id var=D is on the second line.
C1 C2 C3 C4
A B C
A B D
B E F
B
B
B
A B C
A B D
B E F
A B C
A B D
B E F
B
B
I need to convert so it is:
C1 C2 id C4 C5
AA BBBBBB D E F
AA BBB D E F
AA BBBBB D E F
I apologize for being vague before.
Kevin
------------------------------
Date: Thu, 25 Jul 2013 20:28:15 -0400
From: Sergiy Radyakin <[email protected]>
Subject: Re: st: Using infile with varying lines() per observation
Kevin, considering your described setup the following should work:
type http://radyakin.org/statalist/2013072501/testdata.txt
do http://radyakin.org/statalist/2013072501/readflex.do
Here is the output:
id col1 col2 col3 col4
1 A B C 7
B
2 A B C 1
3 A B C 90
B
B
id col1 col2 col3 col4
1 A BB C 7
2 A B C 1
3 A BBB C 90
It's up to you to make sure that 244 chars is enough for the whole BBB
value and that the numbers are completely located in the first line of
each subject. Id is assumed to be a string.
Hope this helps, Sergiy Radyakin
--
Kevin McConeghy, PharmD, BCPS
833 S Wood St, Chicago, IL 60612
College of Pharmacy, Dept. of Pharmacy Practice
University of Illinois at Chicago
(312)-413-1422, [email protected]
*
* 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/