Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: writing a program that uses TAB results for every observation


From   "T.J. Volant" <[email protected]>
To   [email protected]
Subject   st: writing a program that uses TAB results for every observation
Date   Mon, 26 Mar 2007 08:42:35 -0700 (PDT)

Hello all,

I'm needing to TAB for every observation (of several
million) and pick out only certain results from the
TAB and assign it for the relevant observation. How
would I do that?

Example:

var1 var2
1    A
2    A
3    A
3    B

tab var1 if var2=A
results:
1 33%
2 33%
3 33%

For each of observation where var2=A, I would like to
assign sum of the squares of the percentages in the
tab results table in a new variable (say var3). So,
final result would look like:

var1 var2 var3
1    A    3267 (=33^2+33^2+33^2)
2    A    3267
3    A    3267
3    B    -

How can I do this? Thank you very much in advance,

Tj




 
____________________________________________________________________________________
Never miss an email again!
Yahoo! Toolbar alerts you the instant new Mail arrives.
http://tools.search.yahoo.com/toolbar/features/mail/
*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index