Re my program that creates separate variables for each year: easily changed to what you want (I think)
webuse grunfeld,clear
gen allquartile = .
qui forv i=1935/1954 {
egen quartile`i' = cut(mvalue) if year==`i', group(4)
replace allquartile=quartile`i'+1 if quartile`i' < .
}
su allquartile
This will create a single variable for which each firm is classified in the quartile in which it falls each year (which may differ over years).
Kit
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/