Posted by : Netbloggy Friday, October 2, 2015

Any data analysis is not complete without visualization and now it's time for us to learn how to draw simple BAR charts in SAS. We've used PROC SGPLOT to illustrate this. SGPLOT works fine in SAS University Edition too.


Problem 1:

Using the SAS data set Bicycles, produce two vertical bar charts showing frequencies for Country and Model.

Solution:


*Data set BICYCLES;
 
data A15001.A01_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
;
 
title 'Frequency of Countries';
proc sgplot data=A15001.A01_bicycles;
    vbar Country;
    xaxis label='Names of Country';
run;
 
title 'Frequency of Models';
proc sgplot data=A15001.A01_bicycles;
    hbar Model;
    xaxis label='Count';
run;

Output:



Learning:

  • How to draw simple graphs in SAS using SGPLOT
  • How to use different options like XAXIS LABEL while creating BAR Graphs


Leave a Reply

Subscribe to Posts | Subscribe to Comments

Popular Post

Blogger templates

Total Pageviews

Powered by Blogger.

- Copyright © nulldata -Metrominimalist- Powered by Blogger - Designed by Johanes Djogan -