I have a simple task of generating a set of uniformly distributed random number where min/max values would correspond to min/max values taken from an existing variable. Following the advice on The Stata Blog, I drafted the primitive code below:
Unfortunately the code returns the invalid syntax error. Naturally, I will be grateful for any help.
Code:
/* === Example - Random numbers === */ // Data sysuse auto, clear // Loop foreach var of varlist price mpg headroom trunk weight length turn { generate rand_`var' = floor((max(`var')-min(`var')+1)*runiform() + min(`var')) }
Comment