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: Retrieving data from matrix


From   "Francis, Richard N" <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: Retrieving data from matrix
Date   Mon, 2 Dec 2013 21:22:03 +0000

Hi Statalist members,

Have a simple program below, but receive the following error:

"new variables cannot be uniquely named or already defined"

I am using Stata13 with Windows.

The first execution of the loop works fine, then as the second loop is ending, I receive the "new variables cannot be uniquely named or already defined" error message.

Here is the code:

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 k maic sic rmse DFGLS {
      g `v' = .
 }
 gen which = ""

 forval i = 1/`limit' {
         display "Iteration of `i' of `limit"
         replace which = "`: label (id) `i''" in `i'
         dfgls fcf if id == `i' , maxlag(4) ers
		 matrix results=r(results)
		 svmat results
         qui foreach v in k maic sic rmse DFGLS {
                replace `v' = r(`v') in `i'
		
         }
}


In this case, the matrix is 4x5, and the replace `v' command above creates 4 new rows. 

How would I modify this to create only one new row from the matrix?

Any ideas are greatly appreciated!

Thank you for your time and expertise!


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