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

From |
"David Harrison" <david.harrison@icnarc.org> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
RE: st: Calling a scalar within a command. |

Date |
Fri, 25 Feb 2005 09:47:15 -0000 |

You can call scalars directly in your -scatter- command, but there are currently two problems with your code: 1. The scalars are not named `x1' and `x99', but `x'1 and `x'99 (where `x' is the current local macro from the -foreach- loop) 2. You need to force Stata to evaluate the -scalar()- function. You can do this by using `=scalar()' instead. Your first -scatter- would become scatter ta `x', xline(`=scalar(`x'1)' `=scalar(`x'99)') saving(`x', replace) Hope this helps, David 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/ * * 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/

- Prev by Date:
**st: RE: predicted probabilities for Poisson regression** - Next by Date:
**st: RE: label missing** - Previous by thread:
**Re: st: Calling a scalar within a command.** - Next by thread:
**RE: st: Calling a scalar within a command.** - Index(es):

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