*** Oslo register data scheme (ORDC). Hansen, Flemmen and Andersen 2009
*** The program is based on the spss-syntax:
* 	https://www.sv.uio.no/iss/english/research/projects/ordc/documentation/ordc_isco.txt


*** stata program: Øyvind N. Wiborg, University of Oslo
*** v 1.9, 2022



* http://www.sv.uio.no/iss/english/research/projects/ordc/documentation/
* http://www.stata.com/manuals13/rnet.pdf
* https://www.sv.uio.no/iss/english/research/projects/ordc/documentation/ordc_isco.txt


*** requires: isco88 variable + respondents income

capture program drop ordc
program define ordc
version 13

syntax varlist(fv) [if] [in] [,  INComevar(string) Gen(string) GENSIMPlified(string) UPPERcutoff(string) LOWERcutoff(string) oldlab ]

#delimit ;
label define ordcold
1 "Cultural upper"
2 "Professional upper"
3 "Economic upper"
4 "Cultural upper middle"
5 "Professional upper middle"
6 "Economic upper middle"
7 "Cultural lower middle"
8 "Professional lower middle"
9 "Economic lower middle"
10 "Skilled workers"
11 "Unskilled workers"
12 "Primary sector"
13 "Welfare transference"
996 "Occupation title unclassifiable"
997 "Occupation or missing"
998 "Not in labour"
999 "Excluded" , modify
;
#delimit cr




recode `varlist' ///
(1237=1 "Upper class: culture") ///
(2141=1 "Upper class: culture") ///
(2310=1 "Upper class: culture") ///
(2351=1 "Upper class: culture") ///
(2440=1 "Upper class: culture") ///
(2442=1 "Upper class: culture") ///
(2443=1 "Upper class: culture") ///
(2444=1 "Upper class: culture") ///
(2450=1 "Upper class: culture") ///
(2451=1 "Upper class: culture") ///
(2452=1 "Upper class: culture") ///
(2453=1 "Upper class: culture") ///
(2454=1 "Upper class: culture") ///
(2455=1 "Upper class: culture") ///
(1100=2 "Upper class: balanced") ///
(1110=2 "Upper class: balanced") ///
(1120=2 "Upper class: balanced") ///
(1130=2 "Upper class: balanced") ///
(1140=2 "Upper class: balanced") ///
(1141=2 "Upper class: balanced") ///
(1142=2 "Upper class: balanced") ///
(1143=2 "Upper class: balanced") ///
(2140=2 "Upper class: balanced") ///
(2142=2 "Upper class: balanced") ///
(2143=2 "Upper class: balanced") ///
(2144=2 "Upper class: balanced") ///
(2145=2 "Upper class: balanced") ///
(2146=2 "Upper class: balanced") ///
(2147=2 "Upper class: balanced") ///
(2149=2 "Upper class: balanced") ///
(2220=2 "Upper class: balanced") ///
(2221=2 "Upper class: balanced") ///
(2222=2 "Upper class: balanced") ///
(2223=2 "Upper class: balanced") ///
(2224=2 "Upper class: balanced") ///
(2420=2 "Upper class: balanced") ///
(2421=2 "Upper class: balanced") ///
(2422=2 "Upper class: balanced") ///
(2429=2 "Upper class: balanced") ///
(2445=2 "Upper class: balanced") ///
(1210=3 "Upper class: economic") ///
(1231=3 "Upper class: economic") ///
(2300=4 "Upper-middle class: culture") ///
(2320=4 "Upper-middle class: culture") ///
(2340=4 "Upper-middle class: culture") ///
(2350=4 "Upper-middle class: culture") ///
(2352=4 "Upper-middle class: culture") ///
(2359=4 "Upper-middle class: culture") ///
(2430=4 "Upper-middle class: culture") ///
(2431=4 "Upper-middle class: culture") ///
(2432=4 "Upper-middle class: culture") ///
(2460=4 "Upper-middle class: culture") ///
(3472=4 "Upper-middle class: culture") ///
(1227=5 "Upper-middle class: balanced") ///
(1228=5 "Upper-middle class: balanced") ///
(1229=5 "Upper-middle class: balanced") ///
(1230=5 "Upper-middle class: balanced") ///
(2000=5 "Upper-middle class: balanced") ///
(2100=5 "Upper-middle class: balanced") ///
(2110=5 "Upper-middle class: balanced") ///
(2111=5 "Upper-middle class: balanced") ///
(2112=5 "Upper-middle class: balanced") ///
(2113=5 "Upper-middle class: balanced") ///
(2114=5 "Upper-middle class: balanced") ///
(2120=5 "Upper-middle class: balanced") ///
(2121=5 "Upper-middle class: balanced") ///
(2122=5 "Upper-middle class: balanced") ///
(2130=5 "Upper-middle class: balanced") ///
(2131=5 "Upper-middle class: balanced") ///
(2132=5 "Upper-middle class: balanced") ///
(2139=5 "Upper-middle class: balanced") ///
(2148=5 "Upper-middle class: balanced") ///
(2200=5 "Upper-middle class: balanced") ///
(2210=5 "Upper-middle class: balanced") ///
(2211=5 "Upper-middle class: balanced") ///
(2212=5 "Upper-middle class: balanced") ///
(2213=5 "Upper-middle class: balanced") ///
(2229=5 "Upper-middle class: balanced") ///
(2230=5 "Upper-middle class: balanced") ///
(2446=5 "Upper-middle class: balanced") ///
(2470=5 "Upper-middle class: balanced") ///
(3000=5 "Upper-middle class: balanced") ///
(3100=5 "Upper-middle class: balanced") ///
(3110=5 "Upper-middle class: balanced") ///
(3111=5 "Upper-middle class: balanced") ///
(3112=5 "Upper-middle class: balanced") ///
(3113=5 "Upper-middle class: balanced") ///
(3114=5 "Upper-middle class: balanced") ///
(3116=5 "Upper-middle class: balanced") ///
(3117=5 "Upper-middle class: balanced") ///
(3118=5 "Upper-middle class: balanced") ///
(3119=5 "Upper-middle class: balanced") ///
(3132=5 "Upper-middle class: balanced") ///
(3133=5 "Upper-middle class: balanced") ///
(3140=5 "Upper-middle class: balanced") ///
(3141=5 "Upper-middle class: balanced") ///
(3142=5 "Upper-middle class: balanced") ///
(3143=5 "Upper-middle class: balanced") ///
(3144=5 "Upper-middle class: balanced") ///
(3145=5 "Upper-middle class: balanced") ///
(3150=5 "Upper-middle class: balanced") ///
(3151=5 "Upper-middle class: balanced") ///
(3152=5 "Upper-middle class: balanced") ///
(3200=5 "Upper-middle class: balanced") ///
(3210=5 "Upper-middle class: balanced") ///
(3211=5 "Upper-middle class: balanced") ///
(3212=5 "Upper-middle class: balanced") ///
(3213=5 "Upper-middle class: balanced") ///
(3220=5 "Upper-middle class: balanced") ///
(3221=5 "Upper-middle class: balanced") ///
(3222=5 "Upper-middle class: balanced") ///
(3223=5 "Upper-middle class: balanced") ///
(3224=5 "Upper-middle class: balanced") ///
(3226=5 "Upper-middle class: balanced") ///
(3229=5 "Upper-middle class: balanced") ///
(3240=5 "Upper-middle class: balanced") ///
(3241=5 "Upper-middle class: balanced") ///
(3430=5 "Upper-middle class: balanced") ///
(3431=5 "Upper-middle class: balanced") ///
(3434=5 "Upper-middle class: balanced") ///
(3439=5 "Upper-middle class: balanced") ///
(3475=5 "Upper-middle class: balanced") ///
(3410=6 "Lower-middle class: economic") ///
(3411=6 "Lower-middle class: economic") ///
(3412=6 "Lower-middle class: economic") ///
(3413=6 "Lower-middle class: economic") ///
(3414=6 "Lower-middle class: economic") ///
(3415=6 "Lower-middle class: economic") ///
(3416=6 "Lower-middle class: economic") ///
(3417=6 "Lower-middle class: economic") ///
(3419=6 "Lower-middle class: economic") ///
(3420=6 "Lower-middle class: economic") ///
(3421=6 "Lower-middle class: economic") ///
(3422=6 "Lower-middle class: economic") ///
(3423=6 "Lower-middle class: economic") ///
(3429=6 "Lower-middle class: economic") ///
(1200=6 "Upper-middle class: economic") ///
(1220=6 "Upper-middle class: economic") ///
(1221=6 "Upper-middle class: economic") ///
(1222=6 "Upper-middle class: economic") ///
(1223=6 "Upper-middle class: economic") ///
(1224=6 "Upper-middle class: economic") ///
(1225=6 "Upper-middle class: economic") ///
(1226=6 "Upper-middle class: economic") ///
(1232=6 "Upper-middle class: economic") ///
(1233=6 "Upper-middle class: economic") ///
(1234=6 "Upper-middle class: economic") ///
(1235=6 "Upper-middle class: economic") ///
(1236=6 "Upper-middle class: economic") ///
(1239=6 "Upper-middle class: economic") ///
(1300=6 "Upper-middle class: economic") ///
(1310=6 "Upper-middle class: economic") ///
(1311=6 "Upper-middle class: economic") ///
(1312=6 "Upper-middle class: economic") ///
(1313=6 "Upper-middle class: economic") ///
(1314=6 "Upper-middle class: economic") ///
(1315=6 "Upper-middle class: economic") ///
(1316=6 "Upper-middle class: economic") ///
(1317=6 "Upper-middle class: economic") ///
(1318=6 "Upper-middle class: economic") ///
(1319=6 "Upper-middle class: economic") ///
(2410=6 "Upper-middle class: economic") ///
(2411=6 "Upper-middle class: economic") ///
(2412=6 "Upper-middle class: economic") ///
(2419=6 "Upper-middle class: economic") ///
(2441=6 "Upper-middle class: economic") ///
(3432=6 "Upper-middle class: economic") ///
(2330=7 "Lower-middle class: culture") ///
(2331=7 "Lower-middle class: culture") ///
(2332=7 "Lower-middle class: culture") ///
(3131=7 "Lower-middle class: culture") ///
(3300=7 "Lower-middle class: culture") ///
(3310=7 "Lower-middle class: culture") ///
(3320=7 "Lower-middle class: culture") ///
(3330=7 "Lower-middle class: culture") ///
(3340=7 "Lower-middle class: culture") ///
(3470=7 "Lower-middle class: culture") ///
(3471=7 "Lower-middle class: culture") ///
(3473=7 "Lower-middle class: culture") ///
(3474=7 "Lower-middle class: culture") ///
(3480=7 "Lower-middle class: culture") ///
(4140=7 "Lower-middle class: culture") ///
(4141=7 "Lower-middle class: culture") ///
(7324=7 "Lower-middle class: culture") ///
(7330=7 "Lower-middle class: culture") ///
(7331=7 "Lower-middle class: culture") ///
(7332=7 "Lower-middle class: culture") ///
(7340=7 "Lower-middle class: culture") ///
(7343=7 "Lower-middle class: culture") ///
(7344=7 "Lower-middle class: culture") ///
(100=8 "Lower-middle class: balanced") ///
(110=8 "Lower-middle class: balanced") ///
(3115=8 "Lower-middle class: balanced") ///
(3120=8 "Lower-middle class: balanced") ///
(3121=8 "Lower-middle class: balanced") ///
(3122=8 "Lower-middle class: balanced") ///
(3123=8 "Lower-middle class: balanced") ///
(3130=8 "Lower-middle class: balanced") ///
(3139=8 "Lower-middle class: balanced") ///
(3225=8 "Lower-middle class: balanced") ///
(3227=8 "Lower-middle class: balanced") ///
(3228=8 "Lower-middle class: balanced") ///
(3230=8 "Lower-middle class: balanced") ///
(3231=8 "Lower-middle class: balanced") ///
(3232=8 "Lower-middle class: balanced") ///
(3242=8 "Lower-middle class: balanced") ///
(3440=8 "Lower-middle class: balanced") ///
(3441=8 "Lower-middle class: balanced") ///
(3442=8 "Lower-middle class: balanced") ///
(3443=8 "Lower-middle class: balanced") ///
(3444=8 "Lower-middle class: balanced") ///
(3449=8 "Lower-middle class: balanced") ///
(3450=8 "Lower-middle class: balanced") ///
(3460=8 "Lower-middle class: balanced") ///
(4000=8 "Lower-middle class: balanced") ///
(4100=8 "Lower-middle class: balanced") ///
(4110=8 "Lower-middle class: balanced") ///
(4111=8 "Lower-middle class: balanced") ///
(4112=8 "Lower-middle class: balanced") ///
(4113=8 "Lower-middle class: balanced") ///
(4114=8 "Lower-middle class: balanced") ///
(4115=8 "Lower-middle class: balanced") ///
(4120=8 "Lower-middle class: balanced") ///
(4121=8 "Lower-middle class: balanced") ///
(4122=8 "Lower-middle class: balanced") ///
(4130=8 "Lower-middle class: balanced") ///
(4132=8 "Lower-middle class: balanced") ///
(4133=8 "Lower-middle class: balanced") ///
(4143=8 "Lower-middle class: balanced") ///
(4144=8 "Lower-middle class: balanced") ///
(4190=8 "Lower-middle class: balanced") ///
(4212=8 "Lower-middle class: balanced") ///
(4214=8 "Lower-middle class: balanced") ///
(4215=8 "Lower-middle class: balanced") ///
(4220=8 "Lower-middle class: balanced") ///
(4221=8 "Lower-middle class: balanced") ///
(4222=8 "Lower-middle class: balanced") ///
(5100=8 "Lower-middle class: balanced") ///
(5110=8 "Lower-middle class: balanced") ///
(5111=8 "Lower-middle class: balanced") ///
(5113=8 "Lower-middle class: balanced") ///
(5120=8 "Lower-middle class: balanced") ///
(5121=8 "Lower-middle class: balanced") ///
(5143=8 "Lower-middle class: balanced") ///
(5160=8 "Lower-middle class: balanced") ///
(5161=8 "Lower-middle class: balanced") ///
(5162=8 "Lower-middle class: balanced") ///
(5163=8 "Lower-middle class: balanced") ///
(3433=10 "Skilled working class") ///
(4223=10 "Skilled working class") ///
(5122=10 "Skilled working class") ///
(5130=10 "Skilled working class") ///
(5131=10 "Skilled working class") ///
(5132=10 "Skilled working class") ///
(5141=10 "Skilled working class") ///
(5142=10 "Skilled working class") ///
(6113=10 "Skilled working class") ///
(6142=10 "Skilled working class") ///
(7000=10 "Skilled working class") ///
(7100=10 "Skilled working class") ///
(7110=10 "Skilled working class") ///
(7111=10 "Skilled working class") ///
(7112=10 "Skilled working class") ///
(7113=10 "Skilled working class") ///
(7120=10 "Skilled working class") ///
(7121=10 "Skilled working class") ///
(7122=10 "Skilled working class") ///
(7123=10 "Skilled working class") ///
(7124=10 "Skilled working class") ///
(7129=10 "Skilled working class") ///
(7130=10 "Skilled working class") ///
(7131=10 "Skilled working class") ///
(7132=10 "Skilled working class") ///
(7133=10 "Skilled working class") ///
(7134=10 "Skilled working class") ///
(7135=10 "Skilled working class") ///
(7136=10 "Skilled working class") ///
(7137=10 "Skilled working class") ///
(7139=10 "Skilled working class") ///
(7140=10 "Skilled working class") ///
(7141=10 "Skilled working class") ///
(7142=10 "Skilled working class") ///
(7143=10 "Skilled working class") ///
(7200=10 "Skilled working class") ///
(7210=10 "Skilled working class") ///
(7211=10 "Skilled working class") ///
(7212=10 "Skilled working class") ///
(7213=10 "Skilled working class") ///
(7214=10 "Skilled working class") ///
(7215=10 "Skilled working class") ///
(7216=10 "Skilled working class") ///
(7220=10 "Skilled working class") ///
(7221=10 "Skilled working class") ///
(7222=10 "Skilled working class") ///
(7223=10 "Skilled working class") ///
(7224=10 "Skilled working class") ///
(7230=10 "Skilled working class") ///
(7231=10 "Skilled working class") ///
(7232=10 "Skilled working class") ///
(7233=10 "Skilled working class") ///
(7240=10 "Skilled working class") ///
(7241=10 "Skilled working class") ///
(7242=10 "Skilled working class") ///
(7243=10 "Skilled working class") ///
(7244=10 "Skilled working class") ///
(7245=10 "Skilled working class") ///
(7300=10 "Skilled working class") ///
(7310=10 "Skilled working class") ///
(7311=10 "Skilled working class") ///
(7312=10 "Skilled working class") ///
(7313=10 "Skilled working class") ///
(7320=10 "Skilled working class") ///
(7321=10 "Skilled working class") ///
(7322=10 "Skilled working class") ///
(7323=10 "Skilled working class") ///
(7341=10 "Skilled working class") ///
(7342=10 "Skilled working class") ///
(7345=10 "Skilled working class") ///
(7346=10 "Skilled working class") ///
(7400=10 "Skilled working class") ///
(7410=10 "Skilled working class") ///
(7411=10 "Skilled working class") ///
(7412=10 "Skilled working class") ///
(7413=10 "Skilled working class") ///
(7414=10 "Skilled working class") ///
(7415=10 "Skilled working class") ///
(7416=10 "Skilled working class") ///
(7420=10 "Skilled working class") ///
(7421=10 "Skilled working class") ///
(7422=10 "Skilled working class") ///
(7423=10 "Skilled working class") ///
(7424=10 "Skilled working class") ///
(7430=10 "Skilled working class") ///
(7431=10 "Skilled working class") ///
(7432=10 "Skilled working class") ///
(7433=10 "Skilled working class") ///
(7434=10 "Skilled working class") ///
(7435=10 "Skilled working class") ///
(7436=10 "Skilled working class") ///
(7437=10 "Skilled working class") ///
(7440=10 "Skilled working class") ///
(7441=10 "Skilled working class") ///
(7442=10 "Skilled working class") ///
(8100=10 "Skilled working class") ///
(8110=10 "Skilled working class") ///
(8111=10 "Skilled working class") ///
(8112=10 "Skilled working class") ///
(8113=10 "Skilled working class") ///
(8120=10 "Skilled working class") ///
(8121=10 "Skilled working class") ///
(8122=10 "Skilled working class") ///
(8123=10 "Skilled working class") ///
(8124=10 "Skilled working class") ///
(8150=10 "Skilled working class") ///
(8151=10 "Skilled working class") ///
(8152=10 "Skilled working class") ///
(8153=10 "Skilled working class") ///
(8154=10 "Skilled working class") ///
(8155=10 "Skilled working class") ///
(8159=10 "Skilled working class") ///
(8160=10 "Skilled working class") ///
(8161=10 "Skilled working class") ///
(8162=10 "Skilled working class") ///
(8163=10 "Skilled working class") ///
(8170=10 "Skilled working class") ///
(8171=10 "Skilled working class") ///
(8172=10 "Skilled working class") ///
(8211=10 "Skilled working class") ///
(8212=10 "Skilled working class") ///
(8220=10 "Skilled working class") ///
(8250=10 "Skilled working class") ///
(8251=10 "Skilled working class") ///
(8252=10 "Skilled working class") ///
(8310=10 "Skilled working class") ///
(8311=10 "Skilled working class") ///
(8331=10 "Skilled working class") ///
(4131=11 "Unskilled working class") ///
(4142=11 "Unskilled working class") ///
(4210=11 "Unskilled working class") ///
(4211=11 "Unskilled working class") ///
(4213=11 "Unskilled working class") ///
(5112=11 "Unskilled working class") ///
(5123=11 "Unskilled working class") ///
(5133=11 "Unskilled working class") ///
(5139=11 "Unskilled working class") ///
(5140=11 "Unskilled working class") ///
(5149=11 "Unskilled working class") ///
(5150=11 "Unskilled working class") ///
(5151=11 "Unskilled working class") ///
(5152=11 "Unskilled working class") ///
(5169=11 "Unskilled working class") ///
(5200=11 "Unskilled working class") ///
(5210=11 "Unskilled working class") ///
(5220=11 "Unskilled working class") ///
(5230=11 "Unskilled working class") ///
(8000=11 "Unskilled working class") ///
(8130=11 "Unskilled working class") ///
(8131=11 "Unskilled working class") ///
(8139=11 "Unskilled working class") ///
(8140=11 "Unskilled working class") ///
(8141=11 "Unskilled working class") ///
(8142=11 "Unskilled working class") ///
(8143=11 "Unskilled working class") ///
(8200=11 "Unskilled working class") ///
(8210=11 "Unskilled working class") ///
(8221=11 "Unskilled working class") ///
(8222=11 "Unskilled working class") ///
(8223=11 "Unskilled working class") ///
(8224=11 "Unskilled working class") ///
(8229=11 "Unskilled working class") ///
(8230=11 "Unskilled working class") ///
(8231=11 "Unskilled working class") ///
(8232=11 "Unskilled working class") ///
(8240=11 "Unskilled working class") ///
(8253=11 "Unskilled working class") ///
(8260=11 "Unskilled working class") ///
(8261=11 "Unskilled working class") ///
(8262=11 "Unskilled working class") ///
(8263=11 "Unskilled working class") ///
(8264=11 "Unskilled working class") ///
(8265=11 "Unskilled working class") ///
(8266=11 "Unskilled working class") ///
(8269=11 "Unskilled working class") ///
(8270=11 "Unskilled working class") ///
(8271=11 "Unskilled working class") ///
(8272=11 "Unskilled working class") ///
(8273=11 "Unskilled working class") ///
(8274=11 "Unskilled working class") ///
(8275=11 "Unskilled working class") ///
(8276=11 "Unskilled working class") ///
(8277=11 "Unskilled working class") ///
(8278=11 "Unskilled working class") ///
(8279=11 "Unskilled working class") ///
(8280=11 "Unskilled working class") ///
(8281=11 "Unskilled working class") ///
(8282=11 "Unskilled working class") ///
(8283=11 "Unskilled working class") ///
(8284=11 "Unskilled working class") ///
(8285=11 "Unskilled working class") ///
(8286=11 "Unskilled working class") ///
(8287=11 "Unskilled working class") ///
(8290=11 "Unskilled working class") ///
(8300=11 "Unskilled working class") ///
(8312=11 "Unskilled working class") ///
(8320=11 "Unskilled working class") ///
(8321=11 "Unskilled working class") ///
(8322=11 "Unskilled working class") ///
(8323=11 "Unskilled working class") ///
(8324=11 "Unskilled working class") ///
(8330=11 "Unskilled working class") ///
(8332=11 "Unskilled working class") ///
(8333=11 "Unskilled working class") ///
(8334=11 "Unskilled working class") ///
(8340=11 "Unskilled working class") ///
(9000=11 "Unskilled working class") ///
(9100=11 "Unskilled working class") ///
(9110=11 "Unskilled working class") ///
(9111=11 "Unskilled working class") ///
(9112=11 "Unskilled working class") ///
(9113=11 "Unskilled working class") ///
(9120=11 "Unskilled working class") ///
(9130=11 "Unskilled working class") ///
(9131=11 "Unskilled working class") ///
(9132=11 "Unskilled working class") ///
(9133=11 "Unskilled working class") ///
(9140=11 "Unskilled working class") ///
(9141=11 "Unskilled working class") ///
(9142=11 "Unskilled working class") ///
(9150=11 "Unskilled working class") ///
(9151=11 "Unskilled working class") ///
(9152=11 "Unskilled working class") ///
(9153=11 "Unskilled working class") ///
(9160=11 "Unskilled working class") ///
(9161=11 "Unskilled working class") ///
(9162=11 "Unskilled working class") ///
(9300=11 "Unskilled working class") ///
(9310=11 "Unskilled working class") ///
(9311=11 "Unskilled working class") ///
(9312=11 "Unskilled working class") ///
(9313=11 "Unskilled working class") ///
(9320=11 "Unskilled working class") ///
(9321=11 "Unskilled working class") ///
(9322=11 "Unskilled working class") ///
(9330=11 "Unskilled working class") ///
(9331=11 "Unskilled working class") ///
(9332=11 "Unskilled working class") ///
(9333=11 "Unskilled working class") ///
(6000=12 "Primary-sector employees") ///
(6100=12 "Primary-sector employees") ///
(6110=12 "Primary-sector employees") ///
(6111=12 "Primary-sector employees") ///
(6112=12 "Primary-sector employees") ///
(6114=12 "Primary-sector employees") ///
(6120=12 "Primary-sector employees") ///
(6121=12 "Primary-sector employees") ///
(6122=12 "Primary-sector employees") ///
(6123=12 "Primary-sector employees") ///
(6124=12 "Primary-sector employees") ///
(6129=12 "Primary-sector employees") ///
(6130=12 "Primary-sector employees") ///
(6140=12 "Primary-sector employees") ///
(6141=12 "Primary-sector employees") ///
(6150=12 "Primary-sector employees") ///
(6151=12 "Primary-sector employees") ///
(6152=12 "Primary-sector employees") ///
(6153=12 "Primary-sector employees") ///
(6154=12 "Primary-sector employees") ///
(6200=12 "Primary-sector employees") ///
(6210=12 "Primary-sector employees") ///
(9200=12 "Primary-sector employees") ///
(9210=12 "Primary-sector employees") ///
(9211=12 "Primary-sector employees") ///
(9212=12 "Primary-sector employees") ///
(9213=12 "Primary-sector employees") ///
(1000=996 "Not classified") ///
(2400=996 "Not classified") ///
(3400=996 "Not classified") ///
(4200=996 "Not classified") ///
(5000=996 "Not classified") ///
(.=.a) ///
(else = 999 "Not a isco88 std code") ///
 	 , gen("`gen'")


********************************************************************************
* Adjusting remaining econ. classes vertically according to income levels.
* Defaults:
* 				upper >= 90 percentile
*				upper-middle >=50 percentile & < 90 percentile
*				lower-middle < 50 percentile

* User-provided variables have to be ranked ordinally - low to high
*
********************************************************************************

* defaults
if missing("`lowercutoff'") & missing("`uppercutoff'")  {
	su `incomevar' if inlist(`gen',3,6,9) , de
	replace `gen'  = 9 if  `incomevar' <=  r(p50) & `gen'  == 6
	replace `gen'  = 3 if  !missing(`incomevar')  & `incomevar' >=  r(p90) & `gen'  == 6
	di "********   Default cut-off values for econ. classes ***********"
	di "Econ. lower cut-off (50p)= "  `r(p50)'
	di "Econ. upper cut-off (90p)= "  `r(p90)'

}


* user-provided values for cut-offs:
if ~missing("`lowercutoff'") & ~missing("`uppercutoff'")  {
	replace `gen'  = 9 if  `incomevar' <=  `lowercutoff' & `gen'  == 6

	replace `gen'  = 3 if  !missing(`incomevar')  & `incomevar' >=  `uppercutoff'  & `gen'  == 6
	di "********   User defined cut-off values for econ. classes ***********"
	di "Econ. lower cut-off (user)= "  `lowercutoff'
	di "Econ. upper cut-off (user)= "  `uppercutoff'

}

label define `gen' 9 "Lower-middle class: economic", modify
label val `gen'  `gen'

if ~missing("`oldlab'") {
	label value `gen' ordcold
}



********************************************************************************
* This part creates a simplified ordc version - collapsing middle
* and working classes
********************************************************************************

if ~missing("`gensimplified'") {
	recode `gen' (1=1 "Cultural upper") (2=2 "Prof. upper") (3=3 "Econ. upper") ///
	(4 7 = 4 "Cult. Middle") (5 8 = 5 "Prof. middle") (6 9 = 6 "Econ. middle") ///
	(10 11 = 7 "Working class") (12 = 8 "Farmers") (13=9) (90/max = .) , gen("`gensimplified'")

}




end