Hi,

Please consider this example data:
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str11 id float(year surgerydate dischargedate)
"251546/3"  2007 17258 17280
"251546/3"  2007 17258 17280
"991523/01" 2007 17259 17266
"622810/3"  2007 17259 17265
"992424/01" 2007 17260 17272
"991880/01" 2007 17260 17267
"992424/01" 2007 17260 17272
"960950/2"  2007 17260 17268
"990923/01" 2007 17261 17270
"697025/4"  2007 17261 17274
"108844/01" 2007 17261 17263
"820882/4"  2007 17261 17261
"127408/2"  2007 17261 17269
"992102/01" 2007 17261 17265
"185089/3"  2007 17261 17265
"991653/01" 2007 17261 17266
"992890/01" 2007 17261 17269
"127407/2"  2007 17262 17265
"473752/01" 2007 17262 17269
"992952/01" 2007 17262 17269
"517830/2"  2007 17262 17270
"990896/01" 2007 17262 17263
"697023/3"  2007 17262 17269
"990933/01" 2007 17262 17269
"137595/3"  2007 17262 17272
"619651/01" 2007 17262 17263
"992852/01" 2007 17262 17264
"992836/01" 2007 17262 17265
"992243/01" 2007 17262 17266
"386580/3"  2007 17262 17269
"334471/4"  2007 17262 17265
"622842/2"  2007 17262 17263
"499304/01" 2007 17262 17268
"991488/01" 2007 17262 17263
"864925/6"  2007 17262 17268
"991095/01" 2007 17262 17270
"385971/01" 2007 17262 17263
"991188/01" 2007 17262 17269
"992416/01" 2007 17263 17265
"359888/4"  2007 17263 17274
"991753/01" 2007 17263 17273
"992966/01" 2007 17263 17276
"517153/2"  2007 17263 17270
"75960/3"   2007 17263 17265
"829202/2"  2007 17263 17273
"992737/01" 2007 17263 17274
"991309/01" 2007 17263 17293
"1291261/2" 2007 17263 17270
"992975/01" 2007 17264 17268
"991938/01" 2007 17264 17273
"762746/4"  2007 17264 17271
"97798/2"   2007 17264 17272
"992863/01" 2007 17265 17273
"692341/2"  2007 17265 17268
"992437/01" 2007 17265 17276
"993024/01" 2007 17265 17273
"991346/01" 2007 17265 17270
"638566/3"  2007 17265 17274
"496736/2"  2007 17265 17270
"992789/01" 2007 17265 17273
"904146/2"  2007 17265 17307
"991852/01" 2007 17265 17268
"147289/3"  2007 17265 17274
"993075/01" 2007 17265 17266
"21468/2"   2007 17265 17272
"991254/01" 2007 17265 17272
"990941/01" 2007 17265 17274
"871/2"     2007 17265 17275
"804281/2"  2007 17265 17280
"361267/3"  2007 17265 17273
"127406/3"  2007 17265 17275
"61523/2"   2007 17266 17274
"991345/01" 2007 17266 17270
"991926/01" 2007 17266 17275
"987499/5"  2007 17266 17273
"991771/01" 2007 17266 17271
"990869/01" 2007 17266 17276
"323668/5"  2007 17266 17272
"359889/3"  2007 17266 17274
"447549/2"  2007 17266 17269
"992210/01" 2007 17266 17274
"991225/01" 2007 17266 17273
"990939/01" 2007 17266 17271
"991543/01" 2007 17266 17270
"517152/4"  2007 17266 17274
"991913/01" 2007 17266 17270
"757203/2"  2007 17266 17275
"992706/01" 2007 17266 17275
"108843/2"  2007 17266 17277
"992343/01" 2007 17266 17272
"138302/2"  2007 17266 17274
"991431/01" 2007 17266 17274
"1260671/2" 2007 17266 17273
"61523/2"   2007 17266 17274
"108843/2"  2007 17266 17277
"992902/01" 2007 17266 17275
"991562/01" 2007 17266 17287
"510164/2"  2007 17266 17273
"991011/01" 2007 17266 17275
"992474/01" 2007 17266 17270
end
format %td surgerydate
format %td dischargedate
I want to look at readmission within 30 days of discharge from first admission. So, I want to flag IDs that are repeated within 30 days of discharge date. That is, for eg, if any ID has been discharged on 24th April,2007, and has appeared again on surgery date 15th May,2007, I want to flag that ID.

Any help in this regard would be greatly appreciated.

Thanks,