<>
" Do you know how I can retreive the row number of an external text file,
and then use it in a do file as a macro variable `row_no', in a command
such as:
infile variable_list in 2/`row_no' using myfile.txt"
As
*************
help in
*************
says, Stata understands the expression "2/l", as denoting everything but the
first row. I have never used -infile- so you have to make sure that this
does indeed do what you want...
- help file- may also be useful to you, as might be
http://www.stata-journal.com/article.html?article=pr0039
HTH
Martin
-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Eve Corda
Gesendet: Donnerstag, 29. Oktober 2009 10:06
An: [email protected]
Betreff: st: Importing text file into Stata
Dear all,
I have problems importing some kind of text files into Stata. The files
I want to import are separated by several spaces and have a header line.
If I remove the header line I can use the -infile- command (free format)
while specifying variable names and string variables, which might look like:
infile variable_list using myfile.txt
The problem is I have dozens of such files to import and I don't want to
duplicate them, having one copy with headers and another copy without
headers. The -infile- command allows to import only a subset of
observations by specifying -in range- but then I need to know the row
number of each file.
Do you know how I can retreive the row number of an external text file,
and then use it in a do file as a macro variable `row_no', in a command
such as:
infile variable_list in 2/`row_no' using myfile.txt
Or maybe you have another way to solve my problem?
The -infix- command is not a good solution as the variables are not
always located within the same columns in text file.
Thanks a lot in advance for your help.
Best wishes,
Eve