Statalist


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

st: RE: using a string variable with use and save command


From   "Isabelle Deltour" <deltour@cancer.dk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: using a string variable with use and save command
Date   Tue, 13 Oct 2009 11:58:53 +0200

Hi Kushan, 
Have you considered using macros?
See User guide, chapter 18

I would go for something like (as in the examples of foreach)

    foreach file in this.dta that.dta theother.dta {
                append using "`file'"
        }

(note the weird quotes around the file macro label).  

Hope this helps
Isabelle

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Kushan
Thakkar
Sent: Tuesday, October 13, 2009 4:24 AM
To: statalist@hsphsun2.harvard.edu
Subject: st: using a string variable with use and save command

I want to write a program that reads a list of files one by one
(through a for loop) while making changes. In order to do so, i will
need to supply a the file name as a variable with the use command.

For example:

gen filestr = "file name here"
gen fileno = 1
gen infile = filestr + fileno
use infile, clear

Could somebody please help me with the correct syntax for doing this?

Thanks.
Kushan
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index