Hi Statalist,
I hope you are all well during this time.
I am in the process of cleaning up a dataset to get it ready to merge to the master dataset. Essentially, what I have to do is that I have to fill in country names and country numerical codes that are missing for the years 2000-2018 (including for the years 2000 and 2018, if applicable). Basically, they are missing somewhat at random. In the original dataset, the country names were only available if there was a case associated for the country and the year. I just have to fill in the missing gaps before I merge. I have used the following codes that have worked flawlessly until now:
and
(The reference point for the codes above can be found here: https://www.statalist.org/forums/for...within-a-range)
Now, I am receiving the following error messages:
and
I went through the dataset manually last night to see if I can find some errors. From eyesight, it looks okay. (But obviously, it is not). I tried to go through the assert help file, but I still cannot find out what is causing these contradictions. I also tried looking online for help, and found
This is a small window of the data, but these are the variables that are important for the research.
------------------ copy up to and including the previous line ------------------
Listed 100 out of 14022 observations
Use the count() option to list more
Please note that gwno_location is renamed to COW and gwno_location is named to Country.
Thank you in advanced for any help.
MW
I hope you are all well during this time.
I am in the process of cleaning up a dataset to get it ready to merge to the master dataset. Essentially, what I have to do is that I have to fill in country names and country numerical codes that are missing for the years 2000-2018 (including for the years 2000 and 2018, if applicable). Basically, they are missing somewhat at random. In the original dataset, the country names were only available if there was a case associated for the country and the year. I just have to fill in the missing gaps before I merge. I have used the following codes that have worked flawlessly until now:
Code:
gen long obs_no = _n gen block = ceil(_n/19) by block (obs_no), sort: assert year==1999+_n by block (Country), sort: assert Country==Country[_N] | missing(Country) by block (Country): replace Country=Country[_N] sort obs_no
Code:
gen long obs_new = _n gen block1 = ceil(_n/19) by block1 (obs_new), sort: assert year == 1999 + _n by block1 (COW), sort: assert COW == COW[_N] | missing(COW) by block1 (COW): replace COW = COW[_N] sort obs_new
Now, I am receiving the following error messages:
Code:
gen long obs_new = _n . gen block1 = ceil(_n/19) . by block1 (obs_new), sort: assert year == 1999 + _n . by block1 (COW), sort: assert COW == COW[_N] | missing(COW) 7 contradictions in 14,022 observations assertion is false r(9); end of do-file r(9);
Code:
gen long obs_no = _n . gen block = ceil(_n/19) . by block (obs_no), sort: assert year==1999+_n . by block (Country), sort: assert Country==Country[_N] | missing(Country) 6 contradictions in 14,022 observations assertion is false r(9); end of do-file r(9);
Code:
do check, nostop, run check
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input int(year conflict_id) str10 start_date byte ep_end str10 ep_end_date str24 location int gwno_location byte armed_conflict_sending_nonstate 2000 4564 "" . "" "" . 0 2001 4564 "" . "" "" . 0 2002 4564 "" . "" "" . 0 2003 4564 "" . "" "" . 0 2004 4564 "" . "" "" . 0 2005 4564 "" . "" "" . 0 2006 4564 "" . "" "" . 0 2007 4564 "2007-02-09" 1 "2007-12-07" "Iraq" 645 1 2008 4564 "" . "" "" . 0 2009 4564 "" . "" "" . 0 2010 4564 "" . "" "" . 0 2011 4564 "" . "" "" . 0 2012 4564 "" . "" "" . 0 2013 4564 "" . "" "" . 0 2014 4564 "" . "" "" . 0 2015 4564 "" . "" "" . 0 2016 4564 "" . "" "" . 0 2017 4564 "" . "" "" . 0 2018 4564 "" . "" "" . 0 2000 4565 "" . "" "" . 0 2001 4565 "" . "" "" . 0 2002 4565 "" . "" "" . 0 2003 4565 "" . "" "" . 0 2004 4565 "" . "" "" . 0 2005 4565 "" . "" "" . 0 2006 4565 "" . "" "" . 0 2007 4565 "" . "" "" . 0 2008 4565 "2008-01-09" 1 "2008-12-26" "Somalia" 520 1 2009 4565 "" . "" "" . 0 2010 4565 "" . "" "" . 0 2011 4565 "" . "" "" . 0 2012 4565 "" . "" "" . 0 2013 4565 "" . "" "" . 0 2014 4565 "" . "" "" . 0 2015 4565 "" . "" "" . 0 2016 4565 "" . "" "" . 0 2017 4565 "" . "" "" . 0 2018 4565 "" . "" "" . 0 2000 4566 "" . "" "" . 0 2001 4566 "" . "" "" . 0 2002 4566 "2002-03-27" 1 "2002-03-27" "Ghana" 452 1 2003 4566 "" . "" "" . 0 2004 4566 "" . "" "" . 0 2005 4566 "" . "" "" . 0 2006 4566 "" . "" "" . 0 2007 4566 "" . "" "" . 0 2008 4566 "" . "" "" . 0 2009 4566 "" . "" "" . 0 2010 4566 "" . "" "" . 0 2011 4566 "" . "" "" . 0 2012 4566 "" . "" "" . 0 2013 4566 "" . "" "" . 0 2014 4566 "" . "" "" . 0 2015 4566 "" . "" "" . 0 2016 4566 "" . "" "" . 0 2017 4566 "" . "" "" . 0 2018 4566 "" . "" "" . 0 2000 4567 "" . "" "" . 0 2001 4567 "" . "" "" . 0 2002 4567 "" . "" "" . 0 2003 4567 "" . "" "" . 0 2004 4567 "" . "" "" . 0 2005 4567 "" . "" "" . 0 2006 4567 "" . "" "" . 0 2007 4567 "" . "" "" . 0 2008 4567 "2008-01-14" 1 "2008-04-22" "Nigeria" 475 1 2009 4567 "" . "" "" . 0 2010 4567 "" . "" "" . 0 2011 4567 "2008-01-14" 1 "2011-10-17" "Nigeria" 475 1 2012 4567 "" . "" "" . 0 2013 4567 "" . "" "" . 0 2014 4567 "" . "" "" . 0 2015 4567 "" . "" "" . 0 2016 4567 "" . "" "" . 0 2017 4567 "" . "" "" . 0 2018 4567 "" . "" "" . 0 2000 4568 "" . "" "" . 0 2001 4568 "" . "" "" . 0 2002 4568 "" . "" "" . 0 2003 4568 "2003-03-12" 1 "2003-07-11" "Nigeria" 475 1 2004 4568 "" . "" "" . 0 2005 4568 "" . "" "" . 0 2006 4568 "" . "" "" . 0 2007 4568 "" . "" "" . 0 2008 4568 "" . "" "" . 0 2009 4568 "" . "" "" . 0 2010 4568 "" . "" "" . 0 2011 4568 "" . "" "" . 0 2012 4568 "" . "" "" . 0 2013 4568 "" . "" "" . 0 2014 4568 "" . "" "" . 0 2015 4568 "" . "" "" . 0 2016 4568 "" . "" "" . 0 2017 4568 "" . "" "" . 0 2018 4568 "" . "" "" . 0 2000 4569 "" . "" "" . 0 2001 4569 "" . "" "" . 0 2002 4569 "2002-06-30" 0 "" "Ethiopia" 530 1 2003 4569 "2002-06-30" 1 "2003-01-31" "Ethiopia" 530 1 2004 4569 "" . "" "" . 0 end
Listed 100 out of 14022 observations
Use the count() option to list more
Please note that gwno_location is renamed to COW and gwno_location is named to Country.
Thank you in advanced for any help.
MW
Comment