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

Re: st: Calling a scalar within a command.


From   jean ries <ries@ires.ucl.ac.be>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Calling a scalar within a command.
Date   Fri, 25 Feb 2005 10:03:05 +0100

Rajib,

Here is a solution that should work: replace the scalars by local macros.

foreach x in x1 x2 .. xn {
summ `x', d
local p1 = r(p1)
local p99 = r(p99)
scatter ta `x', xline(`p1' `p99') saving(`x' , replace)
scatter ta `x' if `x' >= `p1' & `x' <= `p99' , xline(`p1' `p99') saving(`x't , replace)
}

Hope this helps,

jean


Doogar, Rajib wrote:


I want to call a scalar as an argument in a command e.g. scatter. I have tried to run the following program:
===
foreach x in x1 x2 .. xn {
summ `x', d
sca `x'1 = r(p1)
sca `x'99 = r(p99)
sca list
scatter ta `x', xline(scalar(`x1') scalar(`x99')) saving(`x', replace) scatter ta `x' if `x'>=scalar(`x1') & `x'<=scalar(`x99'), xline(scalar(`x1') scalar(`x99')) saving(`x't, replace)
===
where "scalar()" indicates the places I want to call scalars. Needless to say, this does not work.
Basically, I would like to be able to store a bunch of parameters from the summarize command that I can call freely in subsequent `if' statements or in situations like the scatter command. I cannot find the anything in the manual on calling scalars that fits this context. Any pointers, corrections or suggestions will be a great help.

Many thanks in advance.

r.

Rajib Doogar
doogar@uiuc.edu

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



--
_______________________________________________________

Jean RIES
Institut de recherches économiques et sociales (IRES)
Université catholique de Louvain
Place Montesquieu, 3
1348 Louvain-la-Neuve, Belgium
Phone: +32 10 473071 Fax: +32 10 473945
http://www2.econ.ucl.ac.be/~sexjrs/
_______________________________________________________

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