Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: -hpfilter- question


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: -hpfilter- question
Date   Fri, 13 Feb 2004 12:01:40 -0000

Giorgio Ricchiuti 

> I have to apply the Hoddrick-Prescott Filter Command to my Panel. 
> Unfortunately this command does not permit to use "by". Please, 
> Do you know how I can deal with this problem? I have 143 countries. 
> So create 143 variables and then merge them takes quiet long time. 

Something like this may help. 

tsset country year 

gen hppredict = . 

levels country, local(C) 
qui foreach c of local C { 
	hpfilter myvar if country == `c' 
	replace hppredict = H_myvar if country == `c' 
	drop H_myvar 
} 
	
See also 
http://www.stata.com/support/faqs/data/foreach.html		

Nick 
n.j.cox@durham.ac.uk 

*
*   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/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index