Statalist


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

RE: st: RE: user input as scalar value


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: RE: user input as scalar value
Date   Thu, 26 Jun 2008 17:04:45 +0100

A major correction! Thanks, Nick 

Joseph Coveney
Sent: 26 June 2008 15:49
To: Statalist
Subject: Re: st: RE: user input as scalar value

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