Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: RE: alternative calculation method due to "too many values" / tabulate
From
Nick Cox <[email protected]>
To
"'[email protected]'" <[email protected]>
Subject
st: RE: alternative calculation method due to "too many values" / tabulate
Date
Fri, 2 Mar 2012 14:47:28 +0000
If you could compute a table with 220,000 rows what you do with it? This does seem like a case in which a reduced dataset will be the most convenient solution.
By the way, although -collapse- has already been mentioned for this, in some ways -contract- is more direct.
Alternatively, consider
bysort FSHNETCP3 luse_csp : gen sumcount = sum(count)
by FSHNETCP3 luse_csp : replace sumcount = sumcount[_N]
by FSHNETCP3 luse_csp : gen tag = _n == 1
list FSHNETCP3 luse_csp sumcount if tag
Alternatively, consider -groups- from SSC.
Nick
[email protected]
Martin
I would like to calculate the values which I have in my table in this form:
FSHNETCSP3 luse_csp count
0 10 500
0 1010 124
1 10 500
2 1010 240
2 10 120
3 1010 130
3 10 120
4 10 101
......
To receive the following result:
| luse_csp
FSHNETCSP3 | 0 1 2 3 4
5 10 1000 | Total
-----------+----------------------------------------------------------------
------------------------+----------
0 | 0 9 0 0 5
0 327 3 | 344
1 | 0 0 0 0 0
0 315 0 | 315
2 | 0 5 0 0 0
0 321 5 | 331
3 | 0 0 0 0 0
0 439 1 | 440
4 | 0 0 0 0 0
0 412 8 | 420
5 | 1 2 3 0 0
0 440 0 | 446
6 | 0 0 0 0 0
0 413 7 | 420
........
I used the following command:
. tabulate FSHNETCSP3 luse_csp [fweight = count] in 1/1000
However, because I have 220.000 different FSHNETCSP3 values I get the error
"too many values". I tried the "bigtab" command from the list, but there I
can`t add a weight. I don`t want to use collapse because I need the exact
values for further calculations.
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/