Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: using eqany


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: using eqany
Date   Fri, 28 Jun 2002 10:32:49 +0100

DANIEL CARO
>
> I am using -eqany- command to select the cases where an 'id' variable is
> equal to a group of numbers:
>
> #delimit ;
> egen dani=eqany(cod_mod), v(209940 210328     233098    233288    236117
> 236190    236448    238642    238675     238717    238758    240333
> 262196    262956    262964    275446     275453    275529    275735
> 275792    275800    286468    305607     305771    309302    309898
> 325548    327387    329565    340323     355974    356071    356089
> 372524    372565    372714    373266     394254    395434    411736
> 421339    421396    427427    427864     437343    437368    437376
> 452581    452623    452656    452805     452920    452938    467142
> 469700    478065    502054    504993     508267    515668    520064
> 521013    536219    536714    547927     554105    565176    567750
> 570648    576371    576439    579110     579151    579573    579771
> 580811    581744    583591    587626     594697    594895    600692
> 615906    621037    643841    647057     649673    668897    680785
> 685016    692442    694570    732321     753616    764969    777656
> 779041    781336    785097    811091     876524    900704    909549
> 919308    920025    926758    1023977    1102078   1127638   1136951
> 1147776   1172782);
>
>
> The command gives me the following error: "varlist not allowed r(101)".
> When I reduce the numlist it is performed with no problem. Does this
> happens because the numlist is to large??, Is there any way to
> set a larger numlist or any other alternative??
>
> I hope someone can help me with this very basic question =)
> Many thanks,

Daniel is, I believe, tripping some limitation to the built-in
command -numlist-, which
is called by -egen, eqany()-. The documented limits to -numlist-
are 1600 elements, far more than the 112 ids in this example.

This can be shown directly: I copied and pasted Daniel's values into a
variable
-id- (and there's an advantage to treating them as a variable, explained
below)
and pushed the variable at -vallist- (STB-60):

. vallist id
209940 210328 233098 233288 236117 236190 236448 238642 238675 238717 238758
240333 262196 262956 262964 27
> 5446 275453 275529 275735 275792 275800 286468 305607 305771 309302 309898
325548 327387 329565 340323 35
> 5974 356071 356089 372524 372565 372714 373266 394254 395434 411736 421339
421396 427427 427864 437343 43
> 7368 437376 452581 452623 452656 452805 452920 452938 467142 469700 478065
502054 504993 508267 515668 52
> 0064 521013 536219 536714 547927 554105 565176 567750 570648 576371 576439
579110 579151 579573 579771 58
> 0811 581744 583591 587626 594697 594895 600692 615906 621037 643841 647057
649673 668897 680785 685016 69
> 2442 694570 732321 753616 764969 777656 779041 781336 785097 811091 876524
900704 909549 919308 920025 92
> 6758 1023977 1102078 1127638 1136951 1147776 1172782

. ret li

macros:
              r(list) : "209940 210328 233098 233288 236117 236190 236448
238642 238675 238717 238758 24033
> 3 262196 262956 262964 275446 275453 275529 275735 275792 275800 286468
305607 305771 309302 309898 32554
> 8 327387 329565 340323 355974 356071 356089 372524 372565 372714 373266
394254 395434 411736 421339 42139
> 6 427427 427864 437343 437368 437376 452581 452623 452656 452805 452920
452938 467142 469700 478065 50205
> 4 504993 508267 515668 520064 521013 536219 536714 547927 554105 565176
567750 570648 576371 576439 57911
> 0 579151 579573 579771 580811 581744 583591 587626 594697 594895 600692
615906 621037 643841 647057 64967
> 3 668897 680785 685016 692442 694570 732321 753616 764969 777656 779041
781336 785097 811091 876524 90070
> 4 909549 919308 920025 926758 1023977 1102078 1127638 1136951 1147776
1172782"

. numlist "`r(list)'", int
varlist not allowed
r(101);

An alternative for this problem is the use of -merge- as a variation on a
trick
documented by Kit Baum at
http://www.stata.com/support/faqs/data/characteristics.html

Put the identifiers you want to select as a single variable -cod_mod- in one
Stata .dta file
and then -merge- it with your main data file. The observations you want
are the intersection of the two, namely _merge == 3. You can choose either
one-to-one or match merging.

Nick
[email protected]

*
*   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