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

st: Looping Dates & IDs

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

Dear All,

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

use data, clear
drop if dov >= d(1jan90)
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)
keep if id==5
save newdata2, replace

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

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

Can this be done?

*   For searches and help try:

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