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
>[email protected]
>
>
>*
>* 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/