- SAS - Dates & Times
- SAS - Macros
- SAS - Input Methods
- SAS - Functions
- SAS - Decision Making
- SAS - Loops
- SAS - Operators
- SAS - Numeric Formats
- SAS - Arrays
- SAS - Strings
- SAS - Variables
- SAS - Data Sets
- SAS - Basic Syntax
- SAS - Program Structure
- SAS - User Interface
- SAS - Environment
- SAS - Overview
- SAS - Home
SAS Data Set Operations
- SAS - Simulations
- SAS - Output Delivery System
- SAS - SQL
- SAS - Format Data Sets
- SAS - Sort Data Sets
- SAS - Subsetting Data Sets
- SAS - Merging Data Sets
- SAS - Concatenate Data Sets
- SAS - Write Data Sets
- SAS - Read Raw Data
SAS Data Representation
SAS Basic Statistical Procedure
- SAS - Hypothesis Testing
- SAS - One-Way Anova
- SAS - Repeated Measure Analysis
- SAS - Fishers Exact Tests
- SAS - Chi-Square
- SAS - Bland-Altman Analysis
- SAS - Linear Regression
- SAS - Correlation Analysis
- SAS - T Tests
- SAS - Cross Tabulations
- SAS - Frequency Distributions
- SAS - Standard Deviation
- SAS - Arithmetic Mean
SAS Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
SAS - Pie Charts
A pie-chart is a representation of values as spces of a circle with different colors. The spces are labeled and the numbers corresponding to each spce is also represented in the chart.
In SAS the pie chart is created using PROC TEMPLATE which takes parameters to control percentage, labels, color, title etc.
Syntax
The basic syntax to create a pie-chart in SAS is −
PROC TEMPLATE; DEFINE STATGRAPH pie; BEGINGRAPH; LAYOUT REGION; PIECHART CATEGORY = variable / DATALABELLOCATION = OUTSIDE CATEGORYDIRECTION = CLOCKWISE START = 180 NAME = pie ; DISCRETELEGEND pie / TITLE = ; ENDLAYOUT; ENDGRAPH; END; RUN;Following is the description of parameters used −
variable is the value for which we create the pie chart.
Simple Pie Chart
In this pie chart we take a single variable form the dataset. The pie chart is created with value of the spces representing the fraction of the count of the variable with respect to the total value of the variable.
Example
In the below example each spce represents the fraction of the type of car from the total number of cars.
PROC SQL; create table CARS1 as SELECT make, model, type, invoice, horsepower, length, weight FROM SASHELP.CARS WHERE make in ( Audi , BMW ) ; RUN; PROC TEMPLATE; DEFINE STATGRAPH pie; BEGINGRAPH; LAYOUT REGION; PIECHART CATEGORY = type / DATALABELLOCATION = OUTSIDE CATEGORYDIRECTION = CLOCKWISE START = 180 NAME = pie ; DISCRETELEGEND pie / TITLE = Car Types ; ENDLAYOUT; ENDGRAPH; END; RUN; PROC SGRENDER DATA = cars1 TEMPLATE = pie; RUN;
When we execute the above code, we get the following output −
Pie Chart with Data Labels
In this pie chart we represent both the fractional value as well as the percentage value for each spce. We also change the location of the label to be inside the chart. The style of appearance of the chart is modified by using the DATASKIN option. It uses one of the inbuilt styles, available in the SAS environment.
Example
PROC TEMPLATE; DEFINE STATGRAPH pie; BEGINGRAPH; LAYOUT REGION; PIECHART CATEGORY = type / DATALABELLOCATION = INSIDE DATALABELCONTENT = ALL CATEGORYDIRECTION = CLOCKWISE DATASKIN = SHEEN START = 180 NAME = pie ; DISCRETELEGEND pie / TITLE = Car Types ; ENDLAYOUT; ENDGRAPH; END; RUN; PROC SGRENDER DATA = cars1 TEMPLATE = pie; RUN;
When we execute the above code, we get the following output −
Grouped Pie Chart
In this pie chart the value of the variable presented in the graph is grouped with respect to another variable of the same data set. Each group becomes one circle and the chart has as many concentric circles as the number of groups available.
Example
In the below example we group the chart with respect to the variable named "Make". As there are two values available ("Audi" and "BMW") so we get two concentric circles each representing spces of car types in its own make.
PROC TEMPLATE; DEFINE STATGRAPH pie; BEGINGRAPH; LAYOUT REGION; PIECHART CATEGORY = type / Group = make DATALABELLOCATION = INSIDE DATALABELCONTENT = ALL CATEGORYDIRECTION = CLOCKWISE DATASKIN = SHEEN START = 180 NAME = pie ; DISCRETELEGEND pie / TITLE = Car Types ; ENDLAYOUT; ENDGRAPH; END; RUN; PROC SGRENDER DATA = cars1 TEMPLATE = pie; RUN;
When we execute the above code, we get the following output −
Advertisements