Generating High-Quality Graphics!!!!


                      In this post we speaks about some basic concepts behind SAS/GRAPH software. First you need to have SAS/GRAPH installed on your computer. Without it, you are relegated to using the older style “line printer” type plots using such procedures as PROC CHART and PROC PLOT.
These procedures are fine if you want a quick look at your data in graphical form; however, they are not suitable for presentations.

                       The appearance of graphs and charts is controlled by graphics options and global
statements such as SYMBOL and PATTERN. Options that are set using these statements
act somewhat like titles created using TITLE statements. That is, they remain in effect
until you change them and they are additive. For example, if you already have dots
selected as your plotting symbols, with the color set to black, and you change the color to
red, your plots display with red dots. Lets do some problems.

#Problem:

                       Using the SAS data set Bicycles, we want to produce two vertical bar charts showing frequencies for Country and Model. Use the PATTERN option VALUE=empty.

#Dataset:


*Data set BICYCLES;
data learn.bicycles;
   input Country  & $25.
         Model    & $14.
         Manuf    : $10.
         Units    :   5.
         UnitCost :  comma8.;
   TotalSales = (Units * UnitCost) / 1000;
   format UnitCost TotalSales dollar10.;
   label TotalSales = "Sales in Thousands"
         Manuf = "Manufacturer";
datalines;
USA  Road Bike  Trek 5000 $2,200
USA  Road Bike  Cannondale 2000 $2,100
USA  Mountain Bike  Trek 6000 $1,200
USA  Mountain Bike  Cannondale 4000 $2,700
USA  Hybrid  Trek 4500 $650
France  Road Bike  Trek 3400 $2,500
France  Road Bike  Cannondale 900 $3,700
France  Mountain Bike  Trek 5600 $1,300
France  Mountain Bike  Cannondale  800 $1,899
France  Hybrid  Trek 1100 $540
United Kingdom  Road Bike  Trek 2444 $2,100
United Kingdom  Road Bike  Cannondale  1200 $2,123
United Kingdom  Hybrid  Trek 800 $490
United Kingdom  Hybrid  Cannondale 500 $880
United Kingdom  Mountain Bike  Trek 1211 $1,121
Italy  Hybrid  Trek 700 $690
Italy  Road Bike  Trek 4500  $2,890
Italy  Mountain Bike  Trek 3400  $1,877
;


#Solution:


title Freq of countries;
proc sgplot data=A15028.A28_bicycles;
    vbar Country;
    xaxis label='Country';
run;
 
title 'Freq of Models';
proc sgplot data=A15028.A28_bicycles;
    hbar Model;
    xaxis label='Count';
run;

#Output:





#Explanation:


                     There are lot of normal type of charts such as Proc Plot/Chart as said before, but it wont look like a feel good visuals. So creating a good graphical content there are lot of specific procedures such as gchart, gplot etc., which will gives some good graphical outputs. In the above example we used GPLOT procedure which produced the graphical content for your data. The VBAR and HBAR states abou the position of the graph like vertical or horizontal. Also we can give names for the axis xaxis and yaxis statement. Try the same graph using GCHART!!!


No comments:

Post a Comment