Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Looping Dates & IDs


From   Raphael Fraser <[email protected]>
To   [email protected]
Subject   st: Looping Dates & IDs
Date   Wed, 23 Nov 2005 12:25:46 -0500

Dear All,

I have a do-file called hem.do which I would like to run. But before I
run this do-file I need to drop some observations if dov >= d(1jan90).
Hence

use data, clear
drop if dov >= d(1jan90)
do hem.do
keep if id==5
save newdata1, replace

I would like to repeat this process about a thousand times with
different dates and ids located in a separate file (SEE SNIPPET) then
post to a single file. For example,

use data, clear
drop if dov >= d(2feb90)
do hem.do
keep if id==5
save newdata2, replace

use newdata1, clear
forvalues i=2/1000 {
     append using newdata`i'
}

SNIPPET
id   date_of_onset
5    1jan90
5    2feb90
5    6jun96
7    10oct97
7    25dec99

Can this be done?
Raphael

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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