05-14-2012 11:11 AM
Hi tech savvy friends.
I am looking to write a command on SAS but keep receiving an error.
I have managed to sum the total revenues for a particular industry, in a given year. The individual companies proportion of the industries yearly total revenue is then determined. This weight is then squared to create a concentration score for each company.
05-14-2012 03:31 PM
Shouldn't be too hard - though my solution may not be the most efficient.
/* First, create new SIC codes for herfindahl */
data whateveryourdatasetnameis; set whateveryourdatasetnameis;
if SIC ge 0100 AND le 1799 then herfSIC = 1;
if SIC ge 2000 AND le 3999 then herfSIC = 2;
if SIC ge 4000 AND le 4999 then herfSIC = 3;
if SIC ge 5000 AND le 5199 then herfSIC = 4;
if SIC ge 5200 AND le 5999 then herfSIC = 5;
if SIC ge 6000 AND le 6799 then herfSIC = 6;
if SIC ge 7000 AND le 9999 then herfSIC = 7;
/* Then create sums of revenue by newly-created industry variable herfSIC */
proc summary data = whateveryourdatasetnameis;
var whatevertherevenuevariableiscalled; output out = test sum = herfRev;
/* Assuming the resulting output dataset has the original data as well, now just figure out the portion and square - if not, then first merge which I won't do here */
data test; set test;
herfInd = (whatevertherevenuevariableiscalled / herfRev) ** 2;
05-18-2012 07:44 AM
Hmmm...two thoughts. First, SIC is stored as a numeric variable, correct? Sometimes variables like that look numeric but are actually stored as characters.
Second, maybe change each line to include a second SIC before the le, for example: if SIC ge 0100 AND SIC le 1799 then herfSIC =1;
See if that fixes it.
Need further help from the community? Please ask a new question.