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