Hello.

I have a dataset on weekly hours that individuals worked for each week of the years. For example, the dataset looks like below:
ID hours_1_1997 hours_2_1997 ... hours_52_1997 hours_1_1998 hours_2_1998 ... hours_52_1998
1 10 40 ... 30 30 50 ... 30
Where the numbers 1, 2, and 52 refer to the number of weeks. I wanted to create a variable that sums up the weekly hours worked from September 1997 to May 1998 using foreach loop and egen hours_1997 = rowtotal(...).
I can manually type all the variables that I want to sum(i.e. hours_36_1997, hours_19_1997, ..., hours_52_1997, hours_1_1998, hours_2_1998, ..., hours_17_1998), where 36 indicates the first week of September and 17 refers to the last week of April. However, I was wondering if there is a smart way to specify such range of variables so that I can save the lines and time.

Thank you very much for your help!!!