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]
RE: st: Retrieving data from matrix
From
"Francis, Richard N" <[email protected]>
To
"[email protected]" <[email protected]>
Subject
RE: st: Retrieving data from matrix
Date
Mon, 2 Dec 2013 22:41:23 +0000
Nick,
My bad, I have an extra space in the names feature.
Works beautifully!
I apologize!!
Rick Francis
Associate Professor
Department of Accounting
College of Business Administration
University of Texas at El Paso
500 W. University Avenue
El Paso, TX 79968
Office: 915-747-7953
FAX: 915-747-8618
Email: [email protected]
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Nick Cox
Sent: Monday, December 02, 2013 3:01 PM
To: [email protected]
Subject: Re: st: Retrieving data from matrix
The error is coming from -svmat-. Consider that _second_ time around the loop -svmat- is trying to use the names for new variables that it used _first_ time around the loop. You must exploit the -name()- option to use different names each time around the loop. e.g.
svmat results, names(iter`i'_)
Nick
[email protected]
On 2 December 2013 21:22, Francis, Richard N <[email protected]> wrote:
> 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/
*
* 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/
*
* 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/