Statalist The Stata Listserver


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

st: Re: How to find out if there are different variables in differentwaves of survey data


From   "Michael Blasnik" <michael.blasnik@verizon.net>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Re: How to find out if there are different variables in differentwaves of survey data
Date   Tue, 22 Aug 2006 07:43:14 -0400

Sam Rawlings, Social Sciences and Law 03 wrote::

I have data on the National Family Health Survey (NFHS) for India for two waves of the survey - 92-93 and 98-99. The data I have is pooled for these two waves and I have a dummy variable for each survey (named NFHS92 and NFHS98) where the dummy var = 1 if the observation came from that wave and = 0 if it did not (i.e. NFHS92 is the dummy for the 92 survey, and all obs which are from 1992 have NFHS92=1).

My question is this: I would like to know if there are some variables which are present in one survey but not the other - and am wondering whether there is a way this could be done in Stata.

Currently I am just describing the data by the group NFHS92 - this results in a (very) lengthy list of vars and I am looking for cases where N=0 as indication that that variable is not present in a particular wave of the survey. Is there an easier, or perhaps more sophisticated way to do this, with less output?

Any help would be appreciated,
There are several ways you could accomplish this.  Here's one:

foreach var of varlist _all {
qui count if NFHS92==1 & !mi(`var')
local n92=r(N)
qui count if NFHS92==0 & !mi(`var')
local n98=r(N)
if `n92'>0 & `n98'==0 local only92 "`only92' `var'"
if `n92'==0 & `n98'>0 local only98 "`only98' `var'"
}
di "Variables only in 92 data: `only92' "
di "Variables only in 98 data: `only98' "

Michael Blasnik


*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index