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

st:How to do analysis if the same variable exists in one dataset and is missing or contains no observation in another database?


From   [email protected]
To   [email protected]
Subject   st:How to do analysis if the same variable exists in one dataset and is missing or contains no observation in another database?
Date   Tue, 5 Aug 2003 18:08:12 -0400

Dear stata users,

I have the same survey conducted in several developing countries.
The databases contain almost the same variables (most of the time
coded the same way, but differently sometimes).

In each database, I want to tell stata to check for a variable, and if it does
exist or does
contain observations, to perform some task.

I coded for example:

foreach x of varlist v* {
      capture confirm existence (`x')
      if _rc!=0 {
                      sum `x'
                      recode `x' 1=1 2/3=2 4/*=3
     }
    else {
                  display "`x' does not exist or may contain no observation"
}

But this does not seem to work. I am using stata 8.

How to do if the codification for the same variable is different across
databases?

Many thanks.



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