HI all,
I am experiencing some odd behavior in postfile, Basically i am trying to create a list of value labels in a very large data set. uselabel doesn't appear to work. Therefore i am resorting to more manual methods.
This all works except when i encounter some dodgy labels. Therefore i intended to capture the post statement, write an alternative post statement, and let the loop continue on its merry way.
However, when the post statment errors it appears to close the open postfile, and then next post statement errors out. I thought postfile were supposed to remain open until they are closed.
Any suggestions of how to fix this.
I am experiencing some odd behavior in postfile, Basically i am trying to create a list of value labels in a very large data set. uselabel doesn't appear to work. Therefore i am resorting to more manual methods.
This all works except when i encounter some dodgy labels. Therefore i intended to capture the post statement, write an alternative post statement, and let the loop continue on its merry way.
However, when the post statment errors it appears to close the open postfile, and then next post statement errors out. I thought postfile were supposed to remain open until they are closed.
Any suggestions of how to fix this.
Code:
cap postclose labellist postfile labellist str100 variable str100 value_label level str200 level_txt /// using labellist.dta, replace foreach v of varlist * { local vallab : value label `v' if "`vallab'" !="" { labelsof `v' foreach i in `r(values)' { local value :label (`v') `i' capture post labellist (`"`v'"') (`"`vallab'"') (`i') (`"`value'"') if _rc!=0 { post labellist (`"`v'"') (`"`vallab'"') (`i') (`"Bad label"') } } // End i loop } // end if } // end v loop cap postclose labellist
Comment