Dear Stata-users,

I am struggling with a problem for some days now. I tried different methods but so far, no breakthrough...
I hope to get some help over here, I am desperate.

For my thesis about the effect of certain announcements I need to make use of the short interest. I have the short interest(var: shortint) for different dates(once a month till 2007 and bi-monthly onwards). Now the announcement(announcement day is when variable testertje=1)) is not always on the same day as when the short interest is given. So I have to make an assumption and I will have to "assign" a short interest to this announcement day. So in the case of 29Jan I want to use the short int above(710110) but sometimes when the announcement day is far away of the previous short interest date I want to have the short interest date a few days(for example 2 days) after the announcement. Different_reverse shows the difference between announcement date and given short interest date. I also have different companies with different dates. .

Can i get some help? I tried:

by cusipgroup(time), sort: replace testdifference = testshort[_n-1] if inrange(difference_reverse,0,-15)
(0 real changes made)

by cusipgroup(time), sort: replace testshort = testshort[_n-1] if difference_reverse[_n-1]<0
(3912 real changes made)

Unfortunately this does not do the trick since now also observations which are not on the the announcement day are being changed. I also tried some stuff with conditional commands like this var=1|varx>1

The next step in my thesis will be to compare the short interest on the announcement day to the short interest after the announcement day so you can see a change in short selling.


I hope I can get an anwser!

Thxs



My output:
date time comnam shrout offeringdnumbers1 shortint Car_1daysEW short_shrout2 testertje difference_reverse
15-Dec-03 16054 A A R CORP 31847 798823 .1152936 .0250831 0 -45
15-Jan-04 16085 A A R CORP 31847 710110 -.0245741 .0222975 0 -14
29-Jan-04 16099 A A R CORP 31847 16099 -.0890415 1
13-Feb-04 16114 A A R CORP 32046 846541 .0040389 .0264164 0 15
15-Mar-04 16145 A A R CORP 32046 809643 -.0338605 .025265 0 46
15-Jun-04 16237 A A R CORP 32245 866777 -.008878 .026881 0 -35
15-Jul-04 16267 A A R CORP 32245 672702 .0093428 .0208622 0 -5
20-Jul-04 16272 A A R CORP 32245 16272 -.0102242 1
13-Aug-04 16296 A A R CORP 32245 937750 .0072372 .029082 0 24
15-Dec-05 16785 A A R CORP 33024 1890346 -.0109388 .0572416 0 -42
13-Jan-06 16814 A A R CORP 33092 2125002 -.0449145 .064215 0 -13
26-Jan-06 16827 A A R CORP 33092 16827 -.0919657 1
15-Feb-06 16847 A A R CORP 33498 2767012 .0135222 .0826023 0 20
15-Mar-06 16875 A A R CORP 33498 2594486 .0288767 .077452 0 -47
13-Apr-06 16904 A A R CORP 36349 3175258 .0049173 .0873548 0 -18
01-May-06 16922 A A R CORP 36461 16922 .0254381 1
15-May-06 16936 A A R CORP 36461 3542694 -.0192166 .0971639 0 14
15-Jun-06 16967 A A R CORP 36461 3906339 .0715534 .1071375 0 45