Statalist


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

Re: st: RE: user input as scalar value


From   "Joseph Coveney" <[email protected]>
To   "Statalist" <[email protected]>
Subject   Re: st: RE: user input as scalar value
Date   Thu, 26 Jun 2008 23:49:00 +0900

Nick Cox wrote:

Yes, you can do this.

A canonical exchange within the do file is

di "Enter value for foo: " _request(foo)

after which local foo contains the value typed.

--------------------------------------------------------------------------------

Just a technical clarification:  it's returned in a global macro and not a
local macro.  (I *have* happened to have used it on rare occasion, and have
got stung nearly each time for forgetting this.)

Joseph Coveney

. display in smcl as input "Enter value for foo: " _request(foo)
Enter value for foo: . Bar

. display in smcl as text "local " as result "`foo'"
local

. display in smcl as text "global " as result "$foo"
global Bar

. exit

end of do-file


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