I am quite new to stata and struggling to generate weeks based on fiscal year start and end dates. Stata usually generates weeks based on the calendar year. However, the fiscal year for some firms differs from the calendar year, where stata week IDs are not appropriate. I have gone through various posts but could not find any solution to my problem. My data contains fiscal year start and end dates for each firm along with the daily dates and also the variable fyr which states the ending month of the fiscal year.
* Example generated by -dataex-. To install: ssc install dataex
clear
input double(permno date) float(fyear_start1 fyear_end1) double fyr
10025 19725 19663 20027 10
10025 19726 19663 20027 10
10025 19729 19663 20027 10
10025 19730 19663 20027 10
10025 19731 19663 20027 10
10025 19732 19663 20027 10
10025 19733 19663 20027 10
10025 19736 19663 20027 10
10025 19737 19663 20027 10
10025 19738 19663 20027 10
10025 19739 19663 20027 10
10025 19740 19663 20027 10
10025 19744 19663 20027 10
10025 19745 19663 20027 10
10025 19746 19663 20027 10
10025 19747 19663 20027 10
10025 19750 19663 20027 10
10025 19751 19663 20027 10
10025 19752 19663 20027 10
10025 19753 19663 20027 10
10025 19754 19663 20027 10
10025 19757 19663 20027 10
10025 19758 19663 20027 10
10025 19759 19663 20027 10
10025 19760 19663 20027 10
10025 19761 19663 20027 10
10025 19764 19663 20027 10
10025 19765 19663 20027 10
10025 19766 19663 20027 10
10025 19767 19663 20027 10
10025 19768 19663 20027 10
10025 19772 19663 20027 10
10025 19773 19663 20027 10
10025 19774 19663 20027 10
10025 19775 19663 20027 10
10025 19778 19663 20027 10
10025 19779 19663 20027 10
10025 19780 19663 20027 10
10025 19781 19663 20027 10
end
format %td date
format %td fyear_start1
format %td fyear_end1
Related Posts with Generating week IDs based on fiscal years
Need help on how to interpret coefficient of OLS and PPML Gravity model estimationDear all, I would like to ask for help in interpreting the coefficient of OLS and the coefficient o…
Manual calculation of average marginal effects after melogitDear All, I am trying to calculate the average marginal effects (ame) after running a multilevel lo…
Parse multiple selectors once using insheetjsonHi all, I am trying to build a program that gets data from Statistics Denmark's API using insheetjs…
Stata implementation of Delaunay triangulation + Voronoi tessellation + convex hullDear all, I have been working on a native implementation of Delaunay triangulation, Voronoi tessell…
Margins after reghdfe?Hello Statalisters,. I am running a triple differences linear probability regression, where I am ev…
Subscribe to:
Post Comments (Atom)
0 Response to Generating week IDs based on fiscal years
Post a Comment