Hi,
I have dataset with several companies, and their NAICS code. I want to make a new (additional) column that says e.g. utilities if NAIC-code starts on 21 or 22. .. Thus, I want one additional column containing a "description", ie.the name of the industry, based on the NAICS code.

I have tried several commands, but don't make it work.

This works:
gen NAICS_two_digit = substr(NAICS_CORE_CODE, 1, 2)

But the following don't work:

gen peer_industry = "Agriculture" if NAICS_two_digit = 11
"Utilities" if NAICS_two_digit = 21 | 22
"Manufacturing" if NAICS_two_digit = 31 | 32 | 33
"Construction" if NAICS_two_digit = 23
"Wholesale" if NAICS_two_digit = 42
"Retail" if NAICS_two_digit = 44 | 45
"Transportation" if NAICS_two_digit = 48 | 49

I belive this is a quite trivial problem, however, I don't manage to do it.

Hope someone can help med out there !