BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ncross
Calcite | Level 5

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.

1 ACCEPTED SOLUTION

Accepted Solutions
yeaforme
Calcite | Level 5

Quite right.

modify the proc summary to be:

by herfSIC whateveryouryearvariableiscalled;

instead of just:

by herfSIC;

and that should solve it.

View solution in original post

7 REPLIES 7
yeaforme
Calcite | Level 5

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;

ncross
Calcite | Level 5

Quite impressive. Our methods share similarities

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

yeaforme
Calcite | Level 5

Quite right.

modify the proc summary to be:

by herfSIC whateveryouryearvariableiscalled;

instead of just:

by herfSIC;

and that should solve it.

ncross
Calcite | Level 5

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

yeaforme
Calcite | Level 5

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.

ncross
Calcite | Level 5

Ooh let me see...

ncross
Calcite | Level 5

Worked brilliantly! Hooray for us

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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