BookmarkSubscribeRSS Feed
sastuck
Pyrite | Level 9

Hello again everybody,

 

For my descriptive statistics section I want to have a pie chart that shows the breakdown of CEO compensation. I have data on everything from salary and bonus, to stock and option awards. 

 

This is what the data look like:

 

 

 

0030BGregory S. Daily 1000 29716IPAYMENT INCCo-founder, Chairman and Chief Executive OfficerCEO7080000016.5724.5708724.5724.500....00005000000000000000000001 724.5724.5      277.6-40.379-39.182-39.182-39.182-39.182-39.182  151832142202010 20010201. 20110523.   Co-Founder DailyGregoryS.MALEMr.574.63E+97OTH126 East 56th StreetNew YorkNY10022212-802-7200BUSINESS SERVICES, NECFinancial Transactions Processing, Reserve, and ClData Processing & Outsourced ServicesEX21252232045107389
0030BCarl A. Grimstad 0000 29717IPAYMENT INCCo-Founder, Chairman, Chief Executive Officer and PresidentCEO10001000000083.52083.520002083.52083.500....00004300000000000000000001 2083.52083.5      41.243182.486194.28....  151832286092011 20110523. .. CEO Co-Founder, Chairman, Chief Executive Officer and President GrimstadCarlA.MALEMr.494.63E+97OTH126 East 56th StreetNew YorkNY10022212-802-7200BUSINESS SERVICES, NECFinancial Transactions Processing, Reserve, and ClData Processing & Outsourced ServicesEX21252232045107389
0030BCarl A. Grimstad 0000 29717IPAYMENT INCCo-Founder, Chairman, Chief Executive Officer and PresidentCEO1001.6057750000182.3331958.9381776.6051958.9381958.93800....00004400000000000000000001 1958.9381958.938      0.161-11.17-5.978-5.978-5.978-5.978-5.978  151832286092012 20110523. .. CEO Co-Founder, Chairman, Chief Executive Officer and President GrimstadCarlA.MALEMr.494.63E+97OTH126 East 56th StreetNew YorkNY10022212-802-7200BUSINESS SERVICES, NECFinancial Transactions Processing, Reserve, and ClData Processing & Outsourced ServicesEX21252232045107389
0030BCarl A. Grimstad 0000 29717IPAYMENT INCCo-Founder, Chairman, Chief Executive Officer and PresidentCEO1011.0412000000225.5272436.5672211.042436.5672436.56700....00004500000000000000000001 2436.5672436.567      0.94224.45324.38224.38224.38224.38224.382  151832286092013 20110523. .. CEO Co-Founder, Chairman, Chief Executive Officer and President GrimstadCarlA.MALEMr.494.63E+97OTH126 East 56th StreetNew YorkNY10022212-802-7200BUSINESS SERVICES, NECFinancial Transactions Processing, Reserve, and ClData Processing & Outsourced ServicesEX21252232045107389
0033AJohn F. Young 1000 38315ENERGY FUTURE HOLDINGS CORPChief Executive Officer, President, Director, Member of Executive Committee, Member of Governance & Public Affairs Committee, Chief Executive Officer of Energy Future Intermediate Holding Company LlcCEO12000034052043.62.761210.8266862.18712006862.1875407.1879905.31313080.6595062.009.1012.009.006001950543000340503675420000000036.07400027.6860309.40201 6859.4263454.426      2020166.566166.566110.046166.45934.189  10507297122010 2008012920080101 .. CEO Chief Executive Officer, President, Director, Member of Executive Committee, Chief Executive Officer of Energy Future Intermediate Holding Company LLC, Chief Executive Officer of Energy Future Competitive Holdings C YoungJohnF.MALEMr.6129299Z00OTH1601 Bryan Street, Energy PlazaDallasTX75201214-812-4600ELECTRIC SERVICESElectric Power Generation, Transmission and DistriIndependent Power Producers & Energy TradersEX214221155104911
0033AJohn F. Young 1000 38315ENERGY FUTURE HOLDINGS CORPChief Executive Officer, President, Director, Member of Executive Committee, Member of Governance & Public Affairs Committee, Chief Executive Officer of Energy Future Intermediate Holding Company LlcCEO120005347.508468.63.123105.48415124.707120015124.7079777.20715305.19321650.9651012.222.1012.222.00005560005347.500000600030000039.197006740.6-7.5707042.43202 15121.5849774.084      00120.407120.40780.819120.45182.944  10507297122011 2008012920080101 .. CEO Chief Executive Officer, President, Director, Member of Executive Committee, Chief Executive Officer of Energy Future Intermediate Holding Company LLC, Chief Executive Officer of Energy Future Competitive Holdings C YoungJohnF.MALEMr.6129299Z00OTH1601 Bryan Street, Energy PlazaDallasTX75201214-812-4600ELECTRIC SERVICESElectric Power Generation, Transmission and DistriIndependent Power Producers & Energy TradersEX214221155104911
0033AJohn F. Young 1000 38315ENERGY FUTURE HOLDINGS CORPChief Executive Officer, President, Director, Member of Executive Committee, Chief Executive Officer of Energy Future Intermediate Holding Company Llc, Chief Executive Officer of Energy Future Competitive Holdings CompanyCEO12000525049684.33772.8486770.18512006770.1856245.18512733.85417289.5161012.222.1012.222.00005600525000075003000000168.1730270041.5445990.63668.73602 6765.8486765.848      00-55.238-55.238-36.125-55.257-30.778  10507297122012 2008012920080101 .. CEO Chief Executive Officer, President, Director, Member of Executive Committee, Chief Executive Officer of Energy Future Intermediate Holding Company LLC, Chief Executive Officer of Energy Future Competitive Holdings C YoungJohnF.MALEMr.6129299Z00OTH1601 Bryan Street, Energy PlazaDallasTX75201214-812-4600ELECTRIC SERVICESElectric Power Generation, Transmission and DistriIndependent Power Producers & Energy TradersEX214221155104911
0033AJohn F. Young 1000 38315ENERGY FUTURE HOLDINGS CORPChief Executive Officer, President, Director, Member of Executive Committee, Chief Executive Officer of Energy Future Intermediate Holding Company LLC, Chief Executive Officer of Energy Future Competitive Holdings CompanyCEO1350042005511.375073.1527354.52713507354.5276934.52714177.64317552.6431012.222.1012.222.0000570042000009000000000270046.4357505665.17102 7354.5277354.527      12.512.58.6318.63111.0388.7018.701  10507297122013 2008012920080101 .. CEO Chief Executive Officer, President, Director, Member of Executive Committee, Chief Executive Officer of Energy Future Intermediate Holding Company LLC, Chief Executive Officer of Energy Future Competitive Holdings C YoungJohnF.MALEMr.6129299Z00OTH1601 Bryan Street, Energy PlazaDallasTX75201214-812-4600ELECTRIC SERVICESElectric Power Generation, Transmission and DistriIndependent Power Producers & Energy TradersEX214221155104911

 

Wow, I wish there was a better way to do that.

 

Anyway,  I found the following code online:

 

 /* Set the graphics environment */
goptions reset=all cback=white border htitle=12pt htext=10pt;  

title1 "Types of Vehicles Produced Worldwide";

proc gchart data=sashelp.cars;
   pie type / other=0
              midpoints="Truck" "SUV" "Sedan" "Wagon" "Sports" "Hybrid"
              value=none
              percent=arrow
              slice=arrow
              noheading 
              plabel=(font='Albany AMT/bold' h=1.3 color=depk);
run;
quit; 

I am not really seeing from this example how they incorporate the data from for the pie chart. I can easily replace 

data=sashelp.cars;

for 

data=paper.compustat_execucomp4

but past that I am a little lost. My experience in data visualization basically consists of scatterplots and histograms thus far, so any help is appreciated!

 

Thanks as always!

 

-SAStuck

14 REPLIES 14
Reeza
Super User
Use SGPLOT instead of GCHART and first get your data organized into exactly what you want to display in your charts. GCHARTS are antiquated and the graphics are not as nice, and its harder to use.
sastuck
Pyrite | Level 9

So I'm looking at this code for reference:

 

PROC SORT DATA = sashelp.class
 OUT = class;
 BY age;
RUN;
PROC TEMPLATE;
 DEFINE STATGRAPH pie;
 BEGINGRAPH;
 LAYOUT REGION;
 PIECHART CATEGORY = age /
 DATALABELLOCATION = OUTSIDE
 CATEGORYDIRECTION = CLOCKWISE
 START = 180 NAME = 'pie';
 DISCRETELEGEND 'pie' /
 TITLE = 'Age';
 ENDLAYOUT;
 ENDGRAPH;
 END;
RUN;
PROC SGRENDER DATA = class
 TEMPLATE = pie;
RUN;

What is my BY variable? How do I prepare my data for it to work using this kind of code? Not sure where to begin. 

Reeza
Super User

That's more complex than you need. Find a SGPLOT example instead. 

 


@sastuck wrote:

So I'm looking at this code for reference:

 

PROC SORT DATA = sashelp.class
 OUT = class;
 BY age;
RUN;
PROC TEMPLATE;
 DEFINE STATGRAPH pie;
 BEGINGRAPH;
 LAYOUT REGION;
 PIECHART CATEGORY = age /
 DATALABELLOCATION = OUTSIDE
 CATEGORYDIRECTION = CLOCKWISE
 START = 180 NAME = 'pie';
 DISCRETELEGEND 'pie' /
 TITLE = 'Age';
 ENDLAYOUT;
 ENDGRAPH;
 END;
RUN;
PROC SGRENDER DATA = class
 TEMPLATE = pie;
RUN;

What is my BY variable? How do I prepare my data for it to work using this kind of code? Not sure where to begin. 


 

How do you figure it out? You run the code in the example and look at the source data. Then you map it back to your data, so match the variables in the example to yours, which are the measures being presented, which are the BY variables that map to your data. Then you change the code accordingly. 

 

 

sastuck
Pyrite | Level 9

Having trouble finding any examples online of a pie chart with proc sgplot. I'll keep looking

Reeza
Super User

My bad, SGPLOT doesn't seem to support some Pie Charts, but GTL does. But rather than work with GTL you can use some macros that someone has prebuilt found here:

https://blogs.sas.com/content/graphicallyspeaking/2012/08/26/how-about-some-pie/

sastuck
Pyrite | Level 9

My issue here:

 

%GTLPieChartMacro(data=GTL_Sedans, category=type, response=count,
         title=Share of Market for Sedans, startangle=340,
         DataLabelFontSize=12, responselabel=true,
         percentlabel=false);

Is that my CEO compensation is not a variable segregated by categories but rather different variables for each measure of compensation, so salary, bonus, stock options, and so on. 

Reeza
Super User

So how are you planning to show that in a single pie chart?

 


@sastuck wrote:

My issue here:

 

%GTLPieChartMacro(data=GTL_Sedans, category=type, response=count,
         title=Share of Market for Sedans, startangle=340,
         DataLabelFontSize=12, responselabel=true,
         percentlabel=false);

Is that my CEO compensation is not a variable segregated by categories but rather different variables for each measure of compensation, so salary, bonus, stock options, and so on. 


 

sastuck
Pyrite | Level 9

That's a great question! So what I need is precisely that? If I want to show the composition of the average CEO's salary then I need the variable "components" and then an average for each of the components? Should I do this in a datastep?

sastuck
Pyrite | Level 9

@Reeza , so in order to get this pie chart I need a variable that consists of the different average values which will make up the pie "slices," yes? I know how to compute the averages, but how do I create a variable that consists of just those values so that I can do the pie chart? Here's where i'm at:

 

libname practice "~/425/425_Final_Paper";

*import compustat dataset;
PROC IMPORT out=practice.CompuStat_Execucomp 
		datafile="~/425/425_Final_Paper/CompuStat_Execucomp.csv" DBMS=CSV replace;
	getnames=yes;
	guessingrows=2000;
run;

proc contents data=practice.CompuStat_Execucomp;
run;

proc means data=practice.CompuStat_Execucomp;
	var salary;
	output out=avg mean=avg_salary;
run;

proc means data=practice.CompuStat_Execucomp;
	var bonus;
	output out=avg mean=avg_bonus;
run;

proc means data=practice.CompuStat_Execucomp;
	var option_awards;
	output out=avg mean=avg_optionawards;
run;

Again, I want to show the composition of CEO compensation, broken down into just these three or maybe 4 or 5 (if I include other measure) categories. 

Reeza
Super User

The data set outputted by PROC MEANS (AVG) is what you would use then. 

If you used the same PROC MEANS code three times with three different variables - no need for this by the way - then you're overwriting your output each time. If you comment your code you can avoid logical errors like this. 

The code example I posted in your other questions illustrates how to get a data set with the amounts summarized in a data set.

sastuck
Pyrite | Level 9

Are you referring to this?

 

proc format;
value age_group
low - 13 = 'Pre-Teen'
13 - 15 = 'Teen'
16 - high = 'Adult';
run;

title 'Example of an applied format';
proc print data=sashelp.class;
format age age_group.;
run;


data class;
set sashelp.class;
age_category = put(age, age_group.);
label age_category = 'Age Category';
run;

title 'Example of creating a new variable with the format';
proc print data=class;
run;
Reeza
Super User

No, the one where you asked what feature1-feature3 is. That code, clearly states applied formats to get summaries. 

Your problem here is getting the output summary into a data set for multiple variables at once rather than multiple calls.. 

 

sastuck
Pyrite | Level 9
proc means data=practice.CompuStat_Execucomp noprint;
	by ;
	var avg_salary avg_bonus avg_optionawards;
	output out=practice.compensation_pie median= var= mean= /autoname;
run;

 

Am I getting close? 

Reeza
Super User

You're probably missing something in your BY statement. 

That controls what levels you want the results at, ie groups the results by sex, gender, position.

 

I'd probably try it and see if it give's you the desired results. If not, try changing things. 

sas-innovate-2024.png

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.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 14 replies
  • 1620 views
  • 0 likes
  • 2 in conversation