[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: How to label the value 999999999999

From   Maarten buis <>
Subject   Re: st: How to label the value 999999999999
Date   Wed, 8 Oct 2008 11:45:02 +0100 (BST)

--- Ziad El-Khatib <> wrote:
> I have similar situation to yours (for unknown blood results) and
> code them 999999999999.
> I so as Sergiy suggested or add 'if var!=999999999999' (which can be
> annoying sometimes).

You can simplify that (and thus avoid typos) in a number of ways:

1) Keep the raw data asis, but create a .do-file called
that will contain a set of commands like this:

*----------- -----------------
use rawdata.dta, clear
recode var = . if var == 999999999999
assert var < 999999999999 | var == .
other manipulations of the data
*----------- end ------------

Notice that does not save the "cleaned" data. This is also
a good place to add some checks like the -assert- command. I would also
liberaly add comments to document what you are doing to your data and
why. Than you write another .do file for your analysis, call it, and it would read like this:

*----------- -------------
sum var
reg y x var
some more wonderful analyses
*------------ end ---------

2. You can use -mark- as described in (Jann 2007):

mark touse if var == 999999999999
sum var if touse
reg y x var if touse

Hope this helps,

Ben Jann (2007) Stata tip 44: Get a handle on your sample. The Stata
Journal, 7(2):266--267.

Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room N515

+31 20 5986715

*   For searches and help try:

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