Statalist The Stata Listserver


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

Re: st: consecutive variables


From   Richard Goldstein <[email protected]>
To   [email protected]
Subject   Re: st: consecutive variables
Date   Wed, 20 Dec 2006 13:48:20 -0500

If the numbers are really supposed to be consecutive, then,
when sorted, each value should be the preceding value + 1;
say you also want to know where this is; then type:

li myvar if myvar!=myvar[_n-1]+1

you could also use the -assert- command but that will only
tell you whether there is a problem without telling you
where the problem is

hope this helps,

Rich

Manasi Vydyanath wrote:
Hello - I was wondering whether there was any command for checking
for gaps in a given variable. In other words - supposing I have
"myvar" which is supposed to run from 1 to 256 consecutively. But
there may be gaps in this variable, and it might be missing, say, 69
and 78. Is there a command I can use to detect this sort of thing?

In case anyone is interested, a fuller context of the problem is that
I am creating synthetic cohorts from a series of random cross
sections, and one of the conditions is that there must be no empty
cohort. I wrote a do-file that takes my time-invariant parameters
(age, race and gender) and partitions the set of individuals across
each year. One of the conditions I would like to impose is that there
should be no empty partition, and I was wondering whether there might
be an easy way to check this condtion.)

Thanks!

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