capture program drop anstex program define anstex *! v1.4 gmh sep 22 03 syntax using preserve qui{ clear infile str80 v1 `using' tempvar index gen `index'= index(v1,"\label") keep if `index'>0 gen str80 new=substr(v1,`index',.) drop `index' gen `index'= index(new,"}") replace new=substr(new,1,`index') compress drop if index(new,"fig")>0 gen obs=_n expand 2 sort obs replace new="" if mod(_n,2)==1 replace new = "\ref"+substr(new,7,.) if new~="" drop if index(new,"q")>0 } ren new answers set more off l answers, noobs nodi clean sep(0) set more on restore end