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.
Quite right.
modify the proc summary to be:
by herfSIC whateveryouryearvariableiscalled;
instead of just:
by herfSIC;
and that should solve it.
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;
Quite impressive. Our methods share similarities
However, I believe you are calculating the total revenues on the industry only.
Quite right.
modify the proc summary to be:
by herfSIC whateveryouryearvariableiscalled;
instead of just:
by herfSIC;
and that should solve it.
Hmm seems to be an error with the step 1 PROC.
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.
Ooh let me see...
Worked brilliantly! Hooray for us
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.