Dear Statalst
I'm having problems reading in a text file that has multiple lines and different lines per observation. I am aware of the posting from 13/4/2009 which deals with a similar issue and recommends infix as the root to solve the problem but the structure of my data is slightly different.
All my records are at the household level . The data is essentially the interviewers' remarks on the state of the house sampled. We would like to extract and use some of the information contained in these remarks for our subsequent analysis (eg identify whether the house is considered "small" by the interviewer)
Each new record starts with a 6 digit household code
The third "word" on the first line of each household record indicates the subsequent number of lines of text for that household. So in the data subset posted below household 001003 has 1 further line of text
and household 00104 has 2 lines of text
I can extract the 1st line for each household using the commands
infix hhid 1-6 str remark 8-13 recno 19 using "$find2\test.txt" if recno>0 & recno<9999, clear
drop if hhid==.
save "$find2\hhid", replace
and so i have a household id and a variable (recno) which contains the number of subsequent lines of text for that household
But i cannot work out how to read and join the subsequent rows of text to the relevant household
Any help anyone could give on this would be warmly appreciated
Many thanks
Jonathan Wadsworth
Here is a sample of the data
001003 REMI_M 1
Not yet entiteled to pension under state insurance
001004 REMA_M 2
Rent to outside Landlord
See Cards 0329 0831 0832
001005 REMA_M 2
PAID TO OUTSIDE LANDLORD
SEE CARDS 0051 AND 0945 TO 0949
001005 REMI_M 1
op note: Employer of Earner 1 - Builders, originally entered as P Brown.
001006 REMA_M 2
RENT PAID TO OUTSIDE LANDLORD
SEE CARDS 0051 0945 TO 0948 0950
001007 REMA_M 2
RENT TO OUTSIDE LANDLORD
SEE CARD 0915
001008 REMA_M 2
rent: own £24
We assume this means a notional annual rent
001008 REMI_M 2
£150 P.A. is given as earnings. Interviewer has subsequently pencilled in
57/7d for both earnings cols
001009 REMA_M 2
RENT TO OUTSIDE LANDLORD
SEE CARD 0891
001010 REMA_M 2
PAID TO OUTSIDE LANDLORD
SEE CARD 0063
001011 REMA_M 1
SEE CARD 0784
001011 REMI_M 1
MR THOMAS PAYS RENT TO HEAD FOR FURNISHED ROOMS
I'm having problems reading in a text file that has multiple lines and different lines per observation. I am aware of the posting from 13/4/2009 which deals with a similar issue and recommends infix as the root to solve the problem but the structure of my data is slightly different.
All my records are at the household level . The data is essentially the interviewers' remarks on the state of the house sampled. We would like to extract and use some of the information contained in these remarks for our subsequent analysis (eg identify whether the house is considered "small" by the interviewer)
Each new record starts with a 6 digit household code
The third "word" on the first line of each household record indicates the subsequent number of lines of text for that household. So in the data subset posted below household 001003 has 1 further line of text
and household 00104 has 2 lines of text
I can extract the 1st line for each household using the commands
infix hhid 1-6 str remark 8-13 recno 19 using "$find2\test.txt" if recno>0 & recno<9999, clear
drop if hhid==.
save "$find2\hhid", replace
and so i have a household id and a variable (recno) which contains the number of subsequent lines of text for that household
But i cannot work out how to read and join the subsequent rows of text to the relevant household
Any help anyone could give on this would be warmly appreciated
Many thanks
Jonathan Wadsworth
Here is a sample of the data
001003 REMI_M 1
Not yet entiteled to pension under state insurance
001004 REMA_M 2
Rent to outside Landlord
See Cards 0329 0831 0832
001005 REMA_M 2
PAID TO OUTSIDE LANDLORD
SEE CARDS 0051 AND 0945 TO 0949
001005 REMI_M 1
op note: Employer of Earner 1 - Builders, originally entered as P Brown.
001006 REMA_M 2
RENT PAID TO OUTSIDE LANDLORD
SEE CARDS 0051 0945 TO 0948 0950
001007 REMA_M 2
RENT TO OUTSIDE LANDLORD
SEE CARD 0915
001008 REMA_M 2
rent: own £24
We assume this means a notional annual rent
001008 REMI_M 2
£150 P.A. is given as earnings. Interviewer has subsequently pencilled in
57/7d for both earnings cols
001009 REMA_M 2
RENT TO OUTSIDE LANDLORD
SEE CARD 0891
001010 REMA_M 2
PAID TO OUTSIDE LANDLORD
SEE CARD 0063
001011 REMA_M 1
SEE CARD 0784
001011 REMI_M 1
MR THOMAS PAYS RENT TO HEAD FOR FURNISHED ROOMS

Comment