Hello Statalist,
I have panel data for 989 firms between 1 Jan 1995 until 31Dec 2014. I use business calendar date.
The data as below:
In my regression, I have dummies for day-of-week and holidays for trading around non-weekend holidays.
In order to generate dummy for day-of-week, I use this code;
For the dummy trading around non-weekend holidays, I would like to extract 25dec (Christmas) and 1jan (new year) for every year as a dummy.
I try this code, but I got error.
Can anyone help me to extract the specific date 25dec and 1jan for every year, so that I can generate it as a dummy variable.
Thank you in advance.
Regards,
Rozita
I have panel data for 989 firms between 1 Jan 1995 until 31Dec 2014. I use business calendar date.
The data as below:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float idc str10 dat double(_marketvalue _numbershares _price _returnindex _tradingvalue _tradingvolume _unpaddedprice) str6 company float(caldate bcaldate dow mondaydum) 87 "12_8_2003" 27.01 103900 .26 31.35 . . . "T:BEGR" 16047 2331 5 0 87 "12_9_2003" 27.01 103900 .26 31.35 . . . "T:BEGR" 16048 2332 6 0 87 "12_10_2003" 27.01 103900 .26 31.35 . . . "T:BEGR" 16049 2333 0 0 87 "12_11_2003" 27.01 103900 .26 31.35 . . . "T:BEGR" 16050 2334 1 0 87 "12_12_2003" 27.01 103900 .26 31.35 . . . "T:BEGR" 16051 2335 2 0 87 "" . . . . . . . "" 16052 . . 0 87 "" . . . . . . . "" 16053 . . 0 87 "12_15_2003" 27.01 103900 .26 31.35 . . . "T:BEGR" 16054 2336 3 0 87 "12_16_2003" 24.42 103900 .23 28.34 . 4 .23 "T:BEGR" 16055 2337 4 0 87 "12_17_2003" 24.42 103900 .23 28.34 . . . "T:BEGR" 16056 2338 5 0 87 "12_18_2003" 22.86 103900 .22 26.53 . 35 .22 "T:BEGR" 16057 2339 6 0 87 "12_19_2003" 22.86 103900 .22 26.53 . . . "T:BEGR" 16058 2340 0 0 87 "" . . . . . . . "" 16059 . . 0 87 "" . . . . . . . "" 16060 . . 0 87 "12_22_2003" 22.86 103900 .22 26.53 . . . "T:BEGR" 16061 2341 1 0 87 "12_23_2003" 22.86 103900 .22 26.53 . . . "T:BEGR" 16062 2342 2 0 87 "12_24_2003" 22.86 103900 .22 26.53 . . . "T:BEGR" 16063 2343 3 0 87 "12_25_2003" 22.86 103900 .22 26.53 . . . "T:BEGR" 16064 2344 4 0 87 "12_26_2003" 22.86 103900 .22 26.53 . . . "T:BEGR" 16065 2345 5 0 87 "" . . . . . . . "" 16066 . . 0 87 "" . . . . . . . "" 16067 . . 0 87 "12_29_2003" 22.86 103900 .22 26.53 . . . "T:BEGR" 16068 2346 6 0 87 "12_30_2003" 23.900000000000002 103900 .23 27.740000000000002 . 2 .23 "T:BEGR" 16069 2347 0 0 87 "12_31_2003" 23.900000000000002 103900 .23 27.740000000000002 . . . "T:BEGR" 16070 2348 1 0 87 "_1_1_2004" 23.900000000000002 103900 .23 27.740000000000002 . . . "T:BEGR" 16071 2349 2 0 end format %td caldate format %tbmybcal bcaldate
In order to generate dummy for day-of-week, I use this code;
HTML Code:
gen dow = dow(bcaldate)
HTML Code:
gen mondaydum=1 if bcaldate ==1
HTML Code:
replace mondaydum=0 if mondaydum==.
For the dummy trading around non-weekend holidays, I would like to extract 25dec (Christmas) and 1jan (new year) for every year as a dummy.
I try this code, but I got error.
HTML Code:
gen holiday=1 if bcaldate 25dec* and (-1) if dow (sa) invalid '25dec' r(198);
HTML Code:
gen holiday=1 if bcaldate 25dec* and (+1) if dow (sun) invalid '25dec' r(198);
Thank you in advance.
Regards,
Rozita
Comment