I am currently analysing an employer survey where each observation is an employing organisation. The survey has two industry-classification variables, "NAICS" and "Industry" (data example below). There are some observations for which the categorisations are at odds with each other, for example, one observation has the value "Finance and Insurance" for variable "NAICS" and value "wholesale and retail trade" for variable "Industry". I would now like to drop those observations where the NAICS and Industry classification are incompatible. Specifically, I would like to drop all observations for which the "NAICS" variable takes the value 52 ("Finance and Insurance") and the "Industry" variable takes the value 3 ("Wholesale and Retail Trade"). I know the command
Code:
by NAICS: drop if Industry ==3
Thanks for your time & advice.
Rosa
data example:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float NAICS double Industry
44 3
62 2
31 1
31 1
31 1
42 3
31 1
54 2
51 1
42 3
31 1
42 3
54 5
51 1
44 3
62 5
42 3
62 5
44 3
62 2
54 5
54 2
52 3
51 1
31 1
31 1
62 2
62 2
31 1
52 3
31 1
51 5
52 3
62 5
22 5
72 4
42 3
54 5
81 2
23 1
62 5
61 2
62 2
31 1
31 1
42 3
54 5
54 5
48 5
31 1
31 1
31 1
71 2
62 5
31 1
61 2
54 2
52 3
31 1
31 1
54 5
31 1
54 2
53 3
62 5
54 5
42 3
23 1
62 5
62 2
72 4
62 5
54 2
81 2
62 5
54 2
31 1
52 3
52 3
62 5
54 2
81 5
31 1
62 5
44 3
62 5
23 1
31 1
54 2
72 4
81 5
31 1
23 1
62 5
54 5
31 1
61 2
31 1
62 2
54 2
end
label values NAICS NAICS
label def NAICS 22 "Utilities", modify
label def NAICS 23 "Construction", modify
label def NAICS 31 "Manufacturing", modify
label def NAICS 42 "Wholesale Trade", modify
label def NAICS 44 "Retail Trade", modify
label def NAICS 48 "Transportation and Warehousing", modify
label def NAICS 51 "Information", modify
label def NAICS 52 "Finance and Insurance", modify
label def NAICS 53 "Real Estate and Rental and Leasing", modify
label def NAICS 54 "Professional, Scientific, and Technical Services", modify
label def NAICS 61 "Educational Services", modify
label def NAICS 62 "Health Care and Social Assistance", modify
label def NAICS 71 "Arts, Entertainment, and Recreation", modify
label def NAICS 72 "Accommodation and Food Services", modify
label def NAICS 81 "Other Services (except Public Administration)", modify
label values Industry Industry
label def Industry 1 "Goods Producing", modify
label def Industry 2 "Professional Services", modify
label def Industry 3 "Wholesale and Retail Trade", modify
label def Industry 4 "Finance, Insurance, Real Estate", modify
label def Industry 5 "Other Services", modify
[/CODE]
0 Response to dropping observations with specific values in two different variables
Post a Comment