Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Extract value from user written program


From   "Francis, Richard N" <rnfrancis@utep.edu>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   st: Extract value from user written program
Date   Thu, 26 Dec 2013 03:54:39 +0000

Hi Statalist members,

A user-written program (sroot) requires the following syntax:

srootfix varname [if] [in] [, noconstant trend season(varlist) regress lags(#) generate(string) residuals(string)

... where residuals(string) generates a variable containing the residual terms.

I supply a name for the residual string of -resid- in the following program (near the end of the loop):

destring gvkey, replace
 egen id = group(gvkey), label
 gen date1 = yq(year, fqtr)
 tsset id date1, quarterly
 su id, meanonly
 local limit=r(max)
 foreach v in Z14 Z24 Z34 Z4t Z3t Z2t Z1t {
      g `v' = .
 }
 gen which = ""

 forval i = 1/`limit' {
         display "Iteration of `i' of `limit"
         replace which = "`: label (id) `i''" in `i'
         srootfix fcf if id == `i' ,  residuals (resid)
		 qui foreach v in Z14 Z24 Z34 Z4t Z3t Z2t Z1t {
                replace `v' = r(`v') in `i'
				
         }
}


My question is HOW do I extract the residual values and include them in the replace statement near the end of the loop?

I apologize for the elementary nature of this question.

Thank you!


Rick Francis


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index