Hello everyone,
in my dataset i was having the gaps between dates so i decided to use tsfill command and to fill them.
I have panel dataset, so i created the panel id from the fund number and stock number and declared that to stata by: tsset id year_q
It indeed filled the dataset with missing dates however the rest of the variables are having the missing values like: date, fund number and stock number. The variable "shares" can be ignored since i replaced with the value of 0. The question is how to command stata to fill the missing observations with corresponding values for each variable.
the dataset is presented below:
[CODE]
* Example generated by -dataex-. To install: ssc install dataex
clear
input long date str8 cusip double(fundno shares) float(year_q id)
20909 "00025510" 126793 5000 228 1
21000 "00025510" 126793 5000 229 1
18900 "00028810" 89917 240000 206 2
18991 "00030410" 3369 12724 207 3
18262 "00030410" 86761 60803 199 4
18352 "00030410" 86761 60803 200 4
18443 "00030410" 86761 60803 201 4
18535 "00030410" 86761 60803 202 4
18627 "00030410" 86761 41048 203 4
18717 "00030410" 86761 36208 204 4
18808 "00030410" 86761 36208 205 4
18900 "00030410" 86761 36208 206 4
18991 "00030410" 86761 36208 207 4
19082 "00030410" 86761 22567 208 4
19173 "00030410" 86761 22567 209 4
19264 "00030410" 86761 20867 210 4
19358 "00030410" 86761 20867 211 4
19445 "00030410" 86761 20867 212 4
19537 "00030410" 86761 20867 213 4
19631 "00030410" 86761 20867 214 4
19723 "00030410" 86761 20867 215 4
19813 "00030410" 86761 20867 216 4
18717 "00030410" 88224 10000 204 5
18808 "00030410" 88224 22000 205 5
20269 "00030410" 118985 77 221 6
21455 "00030710" 374 48600 234 7
21549 "00030710" 374 48600 235 7
20088 "00030710" 519 1388 219 8
20178 "00030710" 519 1597 220 8
20269 "00030710" 519 1252 221 8
20361 "00030710" 519 1573 222 8
20453 "00030710" 519 790 223 8
20544 "00030710" 519 881 224 8
20635 "00030710" 519 768 225 8
20727 "00030710" 519 750 226 8
20088 "00030710" 522 325 219 9
20178 "00030710" 522 388 220 9
20269 "00030710" 522 365 221 9
20361 "00030710" 522 516 222 9
20453 "00030710" 522 264 223 9
20544 "00030710" 522 354 224 9
20635 "00030710" 522 305 225 9
20727 "00030710" 522 269 226 9
20088 "00030710" 523 788 219 10
20178 "00030710" 523 896 220 10
20269 "00030710" 523 839 221 10
20361 "00030710" 523 1149 222 10
20453 "00030710" 523 588 223 10
20544 "00030710" 523 724 224 10
20635 "00030710" 523 618 225 10
20727 "00030710" 523 603 226 10
20269 "00030710" 529 10500 221 11
20361 "00030710" 529 11000 222 11
20453 "00030710" 529 1000 223 11
20178 "00030710" 802 162600 220 12
20269 "00030710" 802 287248 221 12
20361 "00030710" 1038 4125 222 13
. "" . 0 223 13
. "" . 0 224 13
. "" . 0 225 13
. "" . 0 226 13
. "" . 0 227 13
. "" . 0 228 13
. "" . 0 229 13
. "" . 0 230 13
. "" . 0 231 13
. "" . 0 232 13
21364 "00030710" 1038 4740 233 13
20088 "00030710" 1119 14700 219 14
20178 "00030710" 1119 14700 220 14
20269 "00030710" 1119 11500 221 14
20269 "00030710" 1350 2397 221 15
20361 "00030710" 1350 728 222 15
20088 "00030710" 1388 70951 219 16
20178 "00030710" 1388 72072 220 16
20178 "00030710" 1888 810 220 17
20269 "00030710" 1888 785 221 17
20178 "00030710" 1889 3154 220 18
20269 "00030710" 1889 3001 221 18
20178 "00030710" 1890 2431 220 19
20269 "00030710" 1890 2430 221 19
21000 "00030710" 1909 14819 229 20
21092 "00030710" 1909 14819 230 20
21182 "00030710" 1909 14819 231 20
21272 "00030710" 1909 14819 232 20
21364 "00030710" 1909 17483 233 20
20088 "00030710" 2010 22360 219 21
21272 "00030710" 2028 89400 232 22
21364 "00030710" 2028 89400 233 22
21455 "00030710" 2028 89400 234 22
21549 "00030710" 2028 89400 235 22
21455 "00030710" 2046 311300 234 23
21549 "00030710" 2046 566938 235 23
20178 "00030710" 2217 33193 220 24
20269 "00030710" 2217 31441 221 24
20088 "00030710" 2284 23500 219 25
20088 "00030710" 2433 45478 219 26
. "" . 0 220 26
20269 "00030710" 2433 144370 221 26
20361 "00030710" 2433 504370 222 26
end
0 Response to tsfill
Post a Comment