Saturday, August 13, 2005

Industry Codes (taken from US Census Site)

Here are 19 industry codes (which Core-Guay 99 use, at least that's what the US Census uses) ;) http://www.census.gov/epcd/www/naicsect.htm

NOTE: since I exclude financial firms as did Core Guay 99, there is no dummy variable for NAICS sector 52, if youi are including it, make sure to add the appropriate dummy variable. :)

/********************************************/
/* NEED TO ADD 19 Industry indicators */
/********************************************/

/*
Code NAICS Sectors
11 Agriculture, Forestry, Fishing and Hunting
21 Mining
22 Utilities
23 Construction
31-33 Manufacturing
42 Wholesale Trade
44-45 Retail Trade
48-49 Transportation and Warehousing
51 Information
52 Finance and Insurance
53 Real Estate and Rental and Leasing
54 Professional, Scientific, and Technical Services
55 Management of Companies and Enterprises
56 Administrative and Support and Waste Management and Remediation Services
61 Education Services
62 Health Care and Social Assistance
71 Arts, Entertainment, and Recreation
72 Accommodation and Food Services
81 Other Services (except Public Administration)
92 Public Administration
*/

DATA temp;
SET temp;
x = ROUND(NAICS/10000);
IF x = 11 THEN ID1 = 1; ELSE ID1 = 0;
IF x = 21 THEN ID2 = 1; ELSE ID2 = 0;
IF x = 22 THEN ID3 = 1; ELSE ID3 = 0;
IF x = 23 THEN ID4 = 1; ELSE ID4 = 0;
IF x in (31,32,33) THEN ID5 = 1; ELSE ID5 = 0;
IF x = 42 THEN ID6 = 1; ELSE ID6 = 0;
IF x in (44,45) THEN ID7 = 1; ELSE ID7 = 0;
IF x in (48,49) THEN ID8 = 1; ELSE ID8 = 0;
IF x = 51 THEN ID9 = 1; ELSE ID9 = 0;
IF x = 53 THEN ID10 = 1; ELSE ID10 = 0;
IF x = 54 THEN ID11 = 1; ELSE ID11 = 0;
IF x = 55 THEN ID12 = 1; ELSE ID12 = 0;
IF x = 56 THEN ID13 = 1; ELSE ID13 = 0;
IF x = 61 THEN ID14 = 1; ELSE ID14 = 0;
IF x = 62 THEN ID15 = 1; ELSE ID15 = 0;
IF x = 71 THEN ID16 = 1; ELSE ID16 = 0;
IF x = 72 THEN ID17 = 1; ELSE ID17 = 0;
IF x = 81 THEN ID18 = 1; ELSE ID18 = 0;
IF x = 92 THEN ID19 = 1; ELSE ID19 = 0;
RUN;

Friday, August 12, 2005

How To MERGE with KEEP and IN

The following SAS code lets you MERGE two datasets whil only pulling the variables that you want from the larger dataset (in this case, crspq.msi) by the variable "date" and the "IF m=1" ensures that any merging will only occur on items on the delist1 dataset (meaning that the sample size of delist1 will remain the same):


DATA delist1;
MERGE delist1(IN=m) crspq.msi(IN=q KEEP= date ewretd);
BY date;
IF m=1;
RUN;