<>
Here is an example for Carlos...
*************
clear*
//10 years
set obs 10
gen year=_n
//expand to 12 months
expand 12
sort year
egen month=seq(), from(1) to(12)
//from http://www.stata-journal.com/sjpdf.html?articlenum=pr0013
//follow special sequences
//generate label for months
tokenize `c(Months)'
forvalues i = 1/12 {
label def month `i' "``i''" , modify
}
label val month month
//values
gen myvalue=rnormal(1000,1000)
//collapse it by year
preserve
collapse (mean) myvalue, by(year)
list, noobs
restore
//or put it in a graph
graph bar (mean) myvalue, over(year)
*************
HTH
Martin
-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Carlos Garcia
Gesendet: Donnerstag, 30. April 2009 15:29
An: [email protected]
Betreff: st: Creating a variable: from monthly to annual
Dear statalist members:
I am running into a problem with a dataset that has observations by
month. I want to create an annual representation of the dataset (or
variable) with the average for the observations in each year.
May you please share me some ideas?
All suggestions will be highly appreciated.
Carlos García
LSU Student
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/