In finance/ accounting research, we have to often create industry dummy variables to control for industry effects.
Often, we obtain four digit SIC code but need to use either two digit or three digit SIC codes.
Q: How to create two/three digit code?
*suppose sic4 is the industry variable containing four digit SIC codes.
**If sic4 is numeric, then
**If sic4 is a string then
**To create industries dummies,
tab sic3, gen(sic3_)
tab sic2, gen(sic2_)
***If this code helped, please support this blog by liking the posts and do please ask more questions, so we can all learn together 😀