Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: How can I save results of a command as a variable


From   "GUO Lei" <[email protected]>
To   [email protected]
Subject   Re: st: How can I save results of a command as a variable
Date   Mon, 02 Apr 2007 18:26:53 -0500

Thanks a lot, I've just tried it and it worked well.

Thank you so much.


From: Jeph Herrin <[email protected]>
Reply-To: [email protected]
To: [email protected]
Subject: Re: st: How can I save results of a command as a variable
Date: Mon, 02 Apr 2007 16:31:08 -0400

After you use any command, you can type -return list-
to get a list of scalar values that may be saved from
the command.
===============Example =============================
. ainequal rank

---------------------------------------
       Inequality measures |       rank
---------------------------+-----------
          Gini coefficient |    0.46679
Theil index (GE(a), a = 1) |    0.36986
---------------------------------------

. return list

macros:
             r(theil) : ".3698631855111214"
              r(gini) : ".4667922732186306"

matrices:
                 r(b) :  2 x 1

.
======================================================

This shows that the Gini coefficient is stored as a string
(not sure why) in the macro r(gini). If you wanted this to
be stored in a variable as a number you would type:

. gen gini = real(r(gini))

Hope this helps,
Jeph




GUO Lei wrote:
Dear all,
I'm not familiar with Stata yet. Could anybody please tell me how can I save an outcome to a variable.

For example, if I'm using ainequal downloaded from internet, and I have the result, one of which is Gini coefficient. My question is how can I save this outcome into some variable?

Thanks ahead! Have a good one!
best,
nick

_________________________________________________________________
??????????,??? Live Messenger; http://get.live.com/messenger/overview
*
* 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/


*
*   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/
_________________________________________________________________
�����������ѽ��н�������ʹ�� Live Messenger; http://get.live.com/messenger/overview
*
* 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