Tiago,
scalar n_x = 100000
generates a numeric scalar
scalar PREV = "`k'"
generates a *string* scalar
So the product of a string and numeric scalar leads to a 'type mismatch' in
scalar affected = PREV*n_x
What you want is to use
scalar PREV = `k'
instead of scalar PREV = "`k'"
Philippe
> -----Original Message-----
> From: [email protected] [mailto:owner-
> [email protected]] On Behalf Of [email protected]
> Sent: Monday, July 07, 2008 7:00 AM
> To: [email protected]
> Subject: st: A simple program with a weird behavior
>
> Dear Statalisters,
>
> It is not rare for me to write Stata programs and face problems like
> the
> one just mentioned below. I will be very grateful for any expert
> opinion.
> Thank you so much for your time.
>
> All the best,
>
>
> Tiago
>
> */------------------------------start--------------------------------
>
> capture program drop example
> *! example v1. TVP 2008
> program define example, rclass byable(recall) sortpreserve
> version 9.0
> syntax [varlist], LOCI(integer) MEANS(real) SDS(real) ORS(string)
> K(real)
> MODEL(string) pa(string) INCREMENT(real)
>
>
> scalar n_x = 100000
> scalar PREV = "`k'"
> scalar affected = PREV*n_x
>
>
>
> end
>
> */------------------------------end--------------------------------
>
>
> . example, means(100) sds(1) ors(1.2,1.3,1.5) loci(4) k(0.3)
> model(genetic_stuff) pa(0.4) increment(0.000001)
> type mismatch
> r(109);
>
> If I delete the last line:
>
> scalar affected = PREV*n_x
>
> the program works fine.
>
>
>
> *
> * 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/