Statalist


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

Re: st: Strange rclass program return


From   "Joao Ricardo F. Lima" <jricardofl@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Strange rclass program return
Date   Sat, 4 Apr 2009 19:32:11 -0300

Carl,

using -scalar- instead -local-...

*******************
cap prog drop test
prog test, rclass
drop _all
qui: set obs 50
gen x = runiform()
sum x
ret scalar testmean = r(mean)
end

test
ret li
*****************

Works for me!

HTH,

Joao Lima

2009/4/4 Joao Ricardo F. Lima <jricardofl@gmail.com>:
> Carl,
>
> try this:
>
> *******
> cap prog drop test
> program test, rclass
> drop _all
> quietly: set obs 50
> generate x = uniform()
> summarize x
> return local testmean = r(mean)
> end
>
> test
> ret li
> *************
> HTH,
>
> Joao Lima
>
> 2009/4/4 Nelson, Carl <chnelson@illinois.edu>:
>> My previous uses of rclass programs with return statements have behaved as documented. But today, I can not get return to return results from rclass programs. I have tried several examples with the same result. The simplest example follows.
>>
>>  do test1
>>
>> . program test, rclass
>>  1.     drop _all
>>  2.     quietly: set obs 50
>>  3.     generate x = uniform()
>>  4.     summarize x
>>  5.     return scalar testmean = r(mean)
>>  6. end
>>
>> . return list
>>
>> .
>> end of do-file
>>
>> I am at a loss as to why return is not returning results. I would appreciate suggestions from much more expert Stata users.
>> Thanks.
>>
>> Carl Nelson
>> University of Illinois
>>
>> *
>> *   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/
>>
>
>
>
> --
> ----------------------------------------
> Joao Ricardo Lima, D.Sc.
> Professor
> UFPB-CCA-DCFS
> Fone: +5538387264913
> Skype: joao_ricardo_lima
> ----------------------------------------
>



-- 
----------------------------------------
Joao Ricardo Lima, D.Sc.
Professor
UFPB-CCA-DCFS
Fone: +5538387264913
Skype: joao_ricardo_lima
----------------------------------------

*
*   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/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index