Statalist


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

st: AW: Importing text file into Stata


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: AW: Importing text file into Stata
Date   Thu, 29 Oct 2009 10:09:47 +0100

<> 

" 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


-- 
Eve CORDA
Statistician

Fondation Jean DAUSSET / CEPH
Unité INSERM U946 (ex U794) - 4ème étage
27 Rue Juliette Dodu
75010 PARIS FRANCE
Tel: +33 (0)1 53 72 50 22
Fax: +33 (0)1 53 72 50 49
e-mail: [email protected]


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/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/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index