clear input father son count 1 1 6313 1 2 2644 1 3 132 2 1 6321 2 2 10883 2 3 294 3 1 2495 3 2 6124 3 3 2471 end label define occ 1 "White collar" 2 "Manual" 3 "Farm" label values father son occ tabulate father son [fw=count], chi2 generate mobility = 2 if father==son replace mobility = 1 if father > son replace mobility = 3 if father < son label define mobile 1 "Upward" 2 "Immobile" 3 "Downward" label values mobility mobile tabulate father mobility [fw=count], chi2 contract father mobility [fw=count], freq(freq) zero tabulate father mobility [fw=freq], chi2 generate sz = (freq==0) poisson freq i.father i.mobility i.sz estat gof