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

From |
Eve Corda <eve.corda@inserm.fr> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: AW: Importing text file into Stata |

Date |
Thu, 29 Oct 2009 10:36:01 +0100 |

Dear Martin, Thank a lot. It helps indeed. Best wishes, Eve Martin Weiss a écrit :

<>" 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 commandsuch 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 filesI 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.txtThe problem is I have dozens of such files to import and I don't want toduplicate them, having one copy with headers and another copy withoutheaders. The -infile- command allows to import only a subset ofobservations by specifying -in range- but then I need to know the rownumber 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 commandsuch 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 notalways 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/

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

**st: AW: Importing text file into Stata***From:*"Martin Weiss" <martin.weiss1@gmx.de>

- Prev by Date:
**Re: st: AW: Adjust after regression involving categorical variables** - Next by Date:
**Re: st: Save estimates in a data file** - Previous by thread:
**st: AW: Importing text file into Stata** - Next by thread:
**st: Qn about Command prvalue** - Index(es):

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