Dear statalist,
I have a set of variables, firm, year, treat, disclosuredate, _id, and _n1. treat is a dummy to indicate whether the firm is subject to a certain treatment; the disclosuredate variable is only available for treatment firms. I use 1 to 1 nearest neighbor matching with replacement to match each control firm to a treatment firm, because disclosuredate variable is missing for control firms, I want to use the disclosuredate of the matched treatment firm to substitute the missing value for the corresponding control firm. From the PSM procedure, I have _id, which represents the identifier from psmatch2, and _n1, which is the ID of nearest neighbor nr. 1.
This sample spans two years, from 2019 to 2020. The sample is perfectly balanced, each firm has an observation in both 2019 and 2020.
I wonder what is the code that can help me to substitute the missing value of disclosuredate for each control firm using the value of its matched treatment firm. Thanks a lot for any kind help!
Here are some data
I have a set of variables, firm, year, treat, disclosuredate, _id, and _n1. treat is a dummy to indicate whether the firm is subject to a certain treatment; the disclosuredate variable is only available for treatment firms. I use 1 to 1 nearest neighbor matching with replacement to match each control firm to a treatment firm, because disclosuredate variable is missing for control firms, I want to use the disclosuredate of the matched treatment firm to substitute the missing value for the corresponding control firm. From the PSM procedure, I have _id, which represents the identifier from psmatch2, and _n1, which is the ID of nearest neighbor nr. 1.
This sample spans two years, from 2019 to 2020. The sample is perfectly balanced, each firm has an observation in both 2019 and 2020.
I wonder what is the code that can help me to substitute the missing value of disclosuredate for each control firm using the value of its matched treatment firm. Thanks a lot for any kind help!
Here are some data
Code:
* Example generated by -dataex-. For more info, type help dataex clear input double firm float(year disclosuredate treat) int(_id _n1) 150 2019 . 0 1419 2418 150 2020 . 0 1284 2375 153 2019 . 0 583 2175 153 2020 . 0 868 2271 156 2019 21949 1 2534 1751 156 2020 21949 1 2557 1818 157 2019 . 0 1757 2535 157 2020 . 0 1876 2578 159 2019 . 0 530 2169 159 2020 . 0 600 2179 166 2019 . 0 1934 2604 166 2020 . 0 1944 2610 338 2019 . 0 1798 2548 338 2020 . 0 1831 2562 400 2019 . 0 1514 2447 400 2020 . 0 1708 2514 403 2019 . 0 1683 2508 403 2020 . 0 1887 2583 408 2019 . 0 1677 2507 408 2020 . 0 1762 2536 411 2019 21949 1 2289 953 411 2020 21949 1 2387 1349 415 2019 . 0 1817 2554 415 2020 . 0 1750 2534 419 2019 . 0 764 2231 419 2020 . 0 913 2277 420 2019 . 0 1780 2540 420 2020 . 0 1795 2548 422 2019 21938 1 2314 1015 422 2020 21938 1 2351 1200 423 2019 . 0 1874 2578 423 2020 . 0 1907 2588 428 2019 . 0 777 2242 428 2020 . 0 936 2285 430 2019 . 0 1225 2362 430 2020 . 0 1297 2377 488 2019 . 0 1690 2508 488 2020 . 0 1793 2547 501 2019 21937 1 2552 1808 501 2020 21937 1 2558 1826 509 2019 . 0 1622 2486 509 2020 . 0 1777 2540 516 2019 . 0 1489 2441 516 2020 . 0 1853 2569 517 2019 21949 1 2566 1839 517 2020 21949 1 2576 1868 519 2019 . 0 1355 2388 519 2020 . 0 1557 2463 520 2019 21937 1 2507 1678 520 2020 21937 1 2505 1671 526 2019 . 0 1397 2411 526 2020 . 0 1703 2513 528 2019 . 0 1693 2510 528 2020 . 0 1744 2533 534 2019 . 0 1628 2488 534 2020 . 0 1805 2550 536 2019 21949 1 2422 1431 536 2020 21949 1 2471 1580 544 2019 21949 1 2368 1252 544 2020 21949 1 2406 1391 545 2019 . 0 1669 2503 545 2020 . 0 1768 2537 546 2019 . 0 1125 2339 546 2020 . 0 1062 2325 547 2019 21949 1 2569 1850 547 2020 21949 1 2619 1952 553 2019 21938 1 2481 1604 553 2020 21938 1 2464 1563 554 2019 . 0 1245 2368 554 2020 . 0 1290 2376 558 2019 21949 1 2561 1831 558 2020 21949 1 2563 1837 559 2019 21949 1 2541 1785 559 2020 21949 1 2571 1857 561 2019 . 0 1583 2472 561 2020 . 0 1653 2499 563 2019 . 0 1969 2622 563 2020 . 0 1970 2622 564 2019 . 0 1545 2462 564 2020 . 0 1671 2505 568 2019 . 0 1963 2621 568 2020 . 0 1995 2631 576 2019 . 0 1420 2418 576 2020 . 0 1649 2495 582 2019 . 0 1639 2493 582 2020 . 0 1738 2530 584 2019 . 0 1584 2473 584 2020 . 0 1705 2513 590 2019 . 0 1400 2411 590 2020 . 0 1317 2382 592 2019 21949 1 2472 1582 592 2020 21949 1 2492 1638 596 2019 . 0 1866 2575 596 2020 . 0 1941 2609 601 2019 . 0 1535 2452 601 2020 . 0 1688 2508 606 2019 . 0 1168 2345 606 2020 . 0 1033 2319 607 2019 21949 1 2458 1540 607 2020 21949 1 2453 1536 end
Comment