Statalist


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

st: RE: RE: RE: user input as scalar value


From   "Buzz Burhans" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: RE: user input as scalar value
Date   Thu, 26 Jun 2008 11:02:59 -0400

Rajesh - I think that if you call your sub-routine do files using -include-
instead of -do- you will retain the locals

Buzz

Buzz Burhans, Ph.D.

Dairy-Tech Group

So. Albany, VT
Phone: 802-755-6842
Cell: 208-320-0829
Fax: 802-755-6842




Email: [email protected]
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Rajesh Tharyan
Sent: Thursday, June 26, 2008 10:34 AM
To: [email protected]
Subject: st: RE: RE: user input as scalar value

Hi,

Thank you very much Nick. That is exactly what I was looking for. 

Martin, I did think about the dialog box. i.e.  to have the do file open
with a dialog box where I set these different parameters. But my entire
program is spilt into 6 or 7 sub programs, that means I would lose the local
macros after each one runs, working around that and programming the dialog
box, seemed too much work for what I was trying to achieve. I wanted quite
simple. But, you are right it may be very useful in certain other
circumstances.


Thanks very much
rajesh






-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Nick Cox
Sent: 26 June 2008 14:53
To: [email protected]
Subject: st: RE: user input as scalar value

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. 

See -help display-. 

I'd rather take arguments from the command line, but that's a matter of
taste. 

Nick
[email protected] 

Rajesh Tharyan

I have a do file, wherein I have a few scalars which I am using to
expand,
loop , as cutoff limits etc. Is it possible to have the do file 
prompt the user to input the value of the scalar, so that I do not have
to
make the changes to the do file.

Suppose I had a do file like

Scalar a=5
......
Expand a
.......

Can I get stata to prompt the user like 

Enter the value for expansion : 
that input then gets stored as a
The code executes..


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

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