Dear All, I find this question here (in Chinese). There are two files. The first one is something like
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input long id str6 interval float day
1 "start"     .
1 "end"       .
2 "start" 20331
2 "end"   20453
4 "start"     .
4 "end"       .
5 "start" 21535
5 "end"   21900
6 "start"     .
6 "end"       .
7 "start"     .
7 "end"       .
8 "start" 21560
8 "end"   21925
9 "start"     .
end
format %tdCCYY-NN-DD day
Taken as an example, for id=2, the period of re-purchase is between "start" (2015Aug31) and "end" (2015Dec31). I need to create a dummy variable which is equal to 1 in this period, 0 otherwise. Given that, I wish to merge this information with another file like
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input long id float day double corr float delay1
2 20437  -.07508226257066927  .3188188
2 20438  -.07500052337700876   .331554
2 20439  -.07617545729621655  .3205806
2 20440  -.03903360826112616 .29350755
2 20639  -.03964094429258676  .3323508
2 20640  -.04574902273836179  .3585479
2 20641  -.05903973917319677  .3838527
2 20642  -.05335531942103895  .3558825
2 20643  -.02964617958757832  .3380436
2 20646 -.023232142864489432  .3460991
2 20647  -.02525021146639929  .3417679
end
format %tdCCYY-NN-DD day
I think the first step might be to -expand- the first data, generate a dummy, and then merge two files. But I have trouble in expanding the data. Any suggestions are highly appreciated.