I have person file that has data like:
I want to compute for each state for every year the average of incwage variable by industry X occupation. Industry is a 3 digit code so is occupation.
Thus, I want for every state-year combination a 999 X 999 matrix that contains average of incwage. My data (this person file above ) runs from 2002 to 2016. Has representation from persons from all 50 us states and wherever for a state-year, Industry X Occupation Cell I dont have any incwage ( no person worked in that industry in that occupation in that state-year) I want it to have missing values.
I am not very conversant with mata but I have a feel that it is easily doable in mata.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input double cpsidp int(ind90ly occ90ly) byte statefip int year long incwage byte wkswork1 19991200324301 641 804 5 2001 9000 52 19991200324302 250 785 5 2001 45000 52 19991200324401 620 274 5 2001 50000 52 19991200324402 842 453 5 2001 8000 42 19991200324801 60 558 5 2001 42000 52 19991200324802 910 338 5 2001 14000 52 19991200324803 910 889 5 2001 2000 52 end label values ind90ly ind90ly_lbl label def ind90ly_lbl 60 "All construction", modify label def ind90ly_lbl 250 "Glass and glass products", modify label def ind90ly_lbl 620 "Auto and home supply stores", modify label def ind90ly_lbl 641 "Eating and drinking places", modify label def ind90ly_lbl 842 "Elementary and secondary schools", modify label def ind90ly_lbl 910 "Justice, public order, and safety", modify label values occ90ly occ90ly_lbl label def occ90ly_lbl 274 "Salespersons, n.e.c.", modify label def occ90ly_lbl 338 "Payroll and timekeeping clerks", modify label def occ90ly_lbl 453 "Janitors", modify label def occ90ly_lbl 558 "Supervisors of construction work", modify label def occ90ly_lbl 785 "Assemblers of electrical equipment", modify label def occ90ly_lbl 804 "Truck, delivery, and tractor drivers", modify label def occ90ly_lbl 889 "Laborers outside construction", modify label values statefip statefip_lbl label def statefip_lbl 5 "Arkansas", modify
Thus, I want for every state-year combination a 999 X 999 matrix that contains average of incwage. My data (this person file above ) runs from 2002 to 2016. Has representation from persons from all 50 us states and wherever for a state-year, Industry X Occupation Cell I dont have any incwage ( no person worked in that industry in that occupation in that state-year) I want it to have missing values.
I am not very conversant with mata but I have a feel that it is easily doable in mata.
Comment