Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

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

From |
Hassan Enayati <hassan.enayati@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: Stata Program Command |

Date |
Fri, 15 Jun 2012 09:43:35 -0400 |

Hello all, I am trying to write my first Stata program and am having some difficulties. At the end of the day, I would like a program (like eststo but not really the same b/c of formatting issues) that grabs certain results from a series of regressions (always a simple regressions) and stores these results in a matrix. Below is the program. The interesting problem is that the matrix contains duplicate rows of the last regression and always only two rows. clear all sysuse auto capture matrix drop X capture program drop grabest program define grabest matrix betas = e(b) matrix beta = betas[1,1] matrix num = e(N) matrix var1 = e(V) scalar se1 = ( var1[1,1])^(0.5) matrix X = beta, num, se1 capture confirm matrix X if _rc==111 { matrix X = beta,num,se1 } else { matrix X = X \ beta,num,se1 } matrix drop betas beta num var1 scalar drop se1 end reg price weight grabest reg length turn grabest reg turn weight grabest matrix list X An additional question I have deals more directly with the construction of the program. How do I create the program so that it generates a matrix with a name I specify. Hence, I would like to be able to write: grabest, matrix(autos1) where autos1 = X in the above example. Thanks! * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**st: RE: Stata Program Command***From:*Nick Cox <n.j.cox@durham.ac.uk>

- Prev by Date:
**Re: st: Creating a data subset with subjects chosen at random** - Next by Date:
**st: RE: sensitivity and specificity with CI's** - Previous by thread:
**st: Creating a data subset with subjects chosen at random** - Next by thread:
**st: RE: Stata Program Command** - Index(es):