Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 72776

Ensure the arguments have the right format

$
0
0
Dear All,

I am writing a simple Stata program that has a few arguments. But the arguments requires different kinds of inputs.
I am writing to see how I can prevent people entering the wrong format.
My program looks like this:

:
capture drop myprogram
program define myprogram
args alpha beta samplesize
in the program, I hope that:
- alpha can be real and between 0 and 1 (open interval).
- beta is real and larger than 0
- sample size is a positive integer

How can I write the -if- condition to make sure that the program stops and user will receive an error message?
I tried to use the command -confirm-, but I am really confused because error message always shows up...

Thank you very much! I look forward to hearing from you!

Best regards
Long






Viewing all articles
Browse latest Browse all 72776

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>