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

st: re: variable number of matrices as arguments


From   Kit Baum <[email protected]>
To   [email protected]
Subject   st: re: variable number of matrices as arguments
Date   Tue, 26 Jul 2005 20:41:47 -0400

Herb said

But what if I want the routine to return, on occasion, some values
calculated over these matrixes such as (for simplicity!) the number
of non-zero cells in the new matrix, B? Assume that this number is
being calculated within the -gprvector- routine in the local `cells':

Use the return statement (presuming that your program is r-class) and you can return the objects as scalars or local macros. In fact you can return matrices this way as well, which would be easier than doing it with the syntax statement.

E.g. (for locals and scalars)

return local breaktype= "`brtype'"
return scalar tmin=`minbreak'
return scalar crit01=`crit01'
return scalar crit05=`crit05'
return local cmd= "zandrews"
return scalar tminobs=`minent'

You may then retrieve the objects using r().


Kit Baum, Boston College Economics
http://ideas.repec.org/e/pba1.html

*
* 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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index