Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

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

st: checking data using assert

From   Raoul Reulen <>
To   "" <>
Subject   st: checking data using assert
Date   Wed, 29 May 2013 03:00:39 +0100

Hi All,

I am currently running several do-files in order to check data. I would like Stata to check whether a certain statement is true, e.g. date of birth (dob) < date of death (dod). If it is not true I want it to display a message saying what the problem is and display the ID numbers for those records were the statement was not true. Lastly, I want to list several variables (e,g. id, dob, dox) to inspect the actual problem.

I have done the following, but wondered if there are easier/more efficient ways of doing it?

.gen byte tag = dod <  dob  
.qui:  levelsof   id    if tag==1
.cap: assert  tag==0
.if _rc di _new as err  "date of death before birth date; see id:   " as text "`r(levels)'"  
.list id dob dod  if tag==1 , noobs N
.drop tag

Many thanks for help! Appreciated as usual!

All the best

*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index