Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down at the end of May, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
"Martin Weiss" <martin.weiss1@gmx.de> |

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

Subject |
st: AW: RE: RE: RE: RE: Is it possible to write a procedure in Stata that interacts with the user? |

Date |
Wed, 14 Apr 2010 13:54:26 +0200 |

<> I could also see Adriaan extending the -syntax- line to include an option to indicate which statistics the user wants. Having Stata query the user during the execution of a -program- is quite unusual - though Adriaan specifically asked for that... HTH Martin -----Ursprüngliche Nachricht----- Von: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Nick Cox Gesendet: Mittwoch, 14. April 2010 13:51 An: statalist@hsphsun2.harvard.edu Betreff: st: RE: RE: RE: RE: Is it possible to write a procedure in Stata that interacts with the user? See also documentation on dialog programming. Nick n.j.cox@durham.ac.uk Hoogendoorn, Adriaan Wow! Thank you, Martin (and Michael) for your reactions to my post. Very helpfull... Martin Weiss [martin.weiss1@gmx.de] Try: ******* cap pr drop my_summarize prog my_summarize vers 11.0 syntax varname di in r "Type 1 if you want mean and standard deviation" _n /* */ "Type 2 if you want median an interquartile range" /* */ _request(myrequest) qui{ su `varlist', det if $myrequest==1 { noi di _n(2) in r "mean: " r(mean) ", sd: " r(sd) } else if $myrequest==2 { noi di _n(2) in r "median: " r(p50) ", iqr: " `=r(p75)-r(p25)' } else{ noi di _n(2) in r "I said 1 or 2..." } } end ******* Then say: ******* sysuse auto, clear my_summarize mpg //upon request: 1 my_summarize mpg //upon request: 2 my_summarize mpg //upon request: 3 ******* Martin Weiss Have you had a look at ******* h display ******* and the -_request- syntax? Hoogendoorn, Adriaan Is it possible to write a procedure that interacts with the user? To give an example of what I mean, suppose that I could create such an interacting procedure "my_summarize" (in a do file) ending with: sysuse auto my_summarize mpg Now I would like Stata to interact with the user, and want Stata to come up with the following suggestion: Type 1 if you want mean and standard deviation or Type 2 if you want median an interquartile range. Please type either 1 or 2. . Typing 1 or 2 from would now result in either the mean and sd of mpg or its median and iqr. Is such an approach (or some alternative) possible in Stata? * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**References**:**st: Is it possible to write a procedure in Stata that interacts with the user?***From:*"Hoogendoorn, Adriaan" <A.Hoogendoorn@ggzingeest.nl>

**st: RE: Is it possible to write a procedure in Stata that interacts with the user?***From:*"Martin Weiss" <martin.weiss1@gmx.de>

**st: RE: RE: Is it possible to write a procedure in Stata that interacts with the user?***From:*"Martin Weiss" <martin.weiss1@gmx.de>

**st: RE: RE: RE: Is it possible to write a procedure in Stata that interacts with the user?***From:*"Hoogendoorn, Adriaan" <A.Hoogendoorn@ggzingeest.nl>

**st: RE: RE: RE: RE: Is it possible to write a procedure in Stata that interacts with the user?***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

- Prev by Date:
**st: RE: RE: RE: RE: Is it possible to write a procedure in Stata that interacts with the user?** - Next by Date:
**RE: st: mata for-if-else** - Previous by thread:
**st: RE: RE: RE: RE: Is it possible to write a procedure in Stata that interacts with the user?** - Next by thread:
**Re: st: Is it possible to write a procedure in Stata that interacts with the user?** - Index(es):