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

From |
"Martin Weiss" <martin.weiss1@gmx.de> |

To |
<statalist@hsphsun2.harvard.edu> |

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: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Eve Corda Gesendet: Donnerstag, 29. Oktober 2009 10:06 An: statalist@hsphsun2.harvard.edu 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: eve.corda@inserm.fr * * 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/

**Follow-Ups**:**Re: st: AW: Importing text file into Stata***From:*Eve Corda <eve.corda@inserm.fr>

**References**:**st: Importing text file into Stata***From:*Eve Corda <eve.corda@inserm.fr>

- Prev by Date:
**st: Importing text file into Stata** - Next by Date:
**st: Qn about Command prvalue** - Previous by thread:
**st: Importing text file into Stata** - Next by thread:
**Re: st: AW: Importing text file into Stata** - Index(es):

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