My answer is that you could create
a macro, with a little programming, but that
it isn't the way you should want to go.
As you want a variable, go straight to
-cumul-.
Nick
n.j.cox@durham.ac.uk
Gijs Dekkers
> I guess this again is a simple question, but I cannot find
> the answer,
> so here we go. Suppose I do a tabulate of a variable vname
>
> .tabulate vname
>
> and the result is
>
> vname Freq. Percent Cum.
>
> -8 2,922 6.49 6.49
> 1 12,586 27.96 34.45
> 2 13,628 30.28 64.73
> 3 15,877 35.27 100.00
> Total 62,449 100.00
>
> Now I want to create a variable Y which has the same
> frequency structure
> as "vname". The below piece of code works fine...
>
> generate x=uniform()*100
> .generate y=-8 if x<6.49
> .replace y=1 if (x>6.49 & x<34.45)
> .replace y=2 if (x>34.45 & x<64.73)
> .replace y=3 if (x>64.73 & x<100)
>
> ...though I am convinced that it could be done more efficient than I
> have done it. But that's not the point: my problem is that I have
> inputted the cumulative frequencies of the TABULATE (i.e.,
> 6.49, 34.45,
> 64.73) directly into the above commands. This is no good, for
> any change
> of the cumulative frequencies would require changing of the
> whole code
> by hand.
>
> So, how does one bring the cumulative frequencies of a TABULATE in a
> local macro, analogous to r(mean) or r(p50) in SUMMARY?
>
*
* 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/