Hello Statalist:
I have weekly data running from week 1 to week 104. I need to organize the data in a 4-week interval to do some statistical analyses. I can generate a new variable and replace the value of that variable, as shown below:
gen myfourweek = .
replace myfourweek == 1 if week >=1 & week <=4
replace myfourweek == 2 if week >=5 & week <=8
.
.
.
However, this is very tedious as I have to run the codes many times. I am wondering if there are easy ways to do the same.
Also, is there a way to summarize the variable, say sales, in a four-week interval, from a weekly sales data. I can summarize sales by week using the codes, below:
table week, statistic (total sales) //week is a weekly time period variable
Can I specify some option in this code to tell stata to summarize sales by a four-week interval ?
Thanks in advance,
Ramesh
I have weekly data running from week 1 to week 104. I need to organize the data in a 4-week interval to do some statistical analyses. I can generate a new variable and replace the value of that variable, as shown below:
gen myfourweek = .
replace myfourweek == 1 if week >=1 & week <=4
replace myfourweek == 2 if week >=5 & week <=8
.
.
.
However, this is very tedious as I have to run the codes many times. I am wondering if there are easy ways to do the same.
Also, is there a way to summarize the variable, say sales, in a four-week interval, from a weekly sales data. I can summarize sales by week using the codes, below:
table week, statistic (total sales) //week is a weekly time period variable
Can I specify some option in this code to tell stata to summarize sales by a four-week interval ?
Thanks in advance,
Ramesh
Comment