Solved
Contributor
Posts: 21

# Error

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.

Accepted Solutions
Solution
‎05-14-2012 08:27 PM
Contributor
Posts: 45

## Re: Herfindahl Index calculation command

Quite right.

modify the proc summary to be:

by herfSIC whateveryouryearvariableiscalled;

by herfSIC;

and that should solve it.

All Replies
Contributor
Posts: 45

## Re: Herfindahl Index calculation command

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;

run;

/* Then create sums of revenue by newly-created industry variable herfSIC */

proc summary data = whateveryourdatasetnameis;

by herfSIC;

var whatevertherevenuevariableiscalled; output out = test sum = herfRev;

run;

/* 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;

run;

Contributor
Posts: 21

## Re: Herfindahl Index calculation command

Quite impressive. Our methods share similarities

However, I believe you are calculating the total revenues on the industry only.

Solution
‎05-14-2012 08:27 PM
Contributor
Posts: 45

## Re: Herfindahl Index calculation command

Quite right.

modify the proc summary to be:

by herfSIC whateveryouryearvariableiscalled;

by herfSIC;

and that should solve it.

Contributor
Posts: 21

## Re: Herfindahl Index calculation command

Hmm seems to be an error with the step 1 PROC.

Contributor
Posts: 45

## Re: Herfindahl Index calculation command

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.

Contributor
Posts: 21

## Re: Herfindahl Index calculation command

Ooh let me see...

Contributor
Posts: 21

## Re: Herfindahl Index calculation command

Worked brilliantly! Hooray for us

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
• 7 replies
• 1675 views
• 3 likes
• 2 in conversation