Statalist The Stata Listserver


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

Re: st: Recoding missing variables


From   "Rodrigo A. Alfaro" <[email protected]>
To   <[email protected]>
Subject   Re: st: Recoding missing variables
Date   Sun, 16 Jul 2006 03:45:38 -0400

Ashwin,

You can try 

foreach x of varlist _all {
replace `x'=. if `x'==99
}

If you are 200% sure that all your variables are less than 98
you can do the following:

foreach x of varlist _all {
replace `x'=. if `x'>98
}

For a subset of variables 

local some "x1 x2 x3"
foreach x of varlist `some' {
replace `x'=. if `x'>98
}

Rodrigo.


----- Original Message ----- 
From: "Ashwin Ananthakrishnan" <[email protected]>
To: "Robert Brummett" <[email protected]>
Cc: <[email protected]>
Sent: Saturday, July 15, 2006 11:23 PM
Subject: Re: st: Recoding missing variables


Thanks for the reply. I do not want to drop the entire
observation as it has nonmissing values for some other
variables. For examples,


        var1     outcome1 var3   var4
obs1     1         2       7     99
obs2     99        99      3      1
obs3      0         2       5     4
obs4      1         0       99    99


For analyses of var1 , i want to include obs1, 3, 4
and for var 3 - obs 1,2, and 3.

However, when i run the regression for outcome1
against var1, var3 or var4, I do not want the "99" to
be included as a legitimate coding for those variables
and hence influence the odds ratio estimate.

Hope that clarifies my question a bit.

Thanks,
Ashwin







--- Robert Brummett <[email protected]> wrote:

> Ashwin,
> 
> I assigned missing values as ".m" (similar to your
> 99) in one of my
> datasets.
> 
> All you have to do is use the "drop" command.
> 
> In your script, before your tables or regression
> script, type:
> 
> drop if variablex == 99
> 
> where you would replace your variable name for
> "variablex".
> 
> This assumes you would not want to use those
> observations for other analysis
> (where other variables may be included you don't
> want to drop).
> 
> There are other ways to ignore those with this
> value, and this assumes that
> no non-missing values are 99 in this variable.
> 
> Let me know if this helps or if you want more ideas
> (other ways are not
> really more complex, but take more time to describe.
> 
> Good luck,
> Robert
> 
> 
> 
> On 7/15/06, Ashwin Ananthakrishnan
> <[email protected]> wrote:
> >
> > Hi,
> >
> > I have a dataset where currently missing values
> are
> > labelled 99 for all variables (which usually have
> > values between 1-15). Is there anyway I can get
> stata
> > to recognize the value 99 as missing variables so
> that
> > they are not included in tables or in regression?
> >
> > Thanks,
> > Ashwin
> >
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam
> protection around
> > http://mail.yahoo.com
> > *
> > *   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/
> >
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
*
*   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/
*
*   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