The top12 pharms

This post was kindly contributed by SAS Analysis - go there to comment and to read the full post.


1. Data import: input/format/label/keep+array
2. GTL can definitely be reused;


data top12;
input rank company & $20. country & $15. revenue comma12.2 netincome comma12.2 employee;
personearn=(netincome/employee)*1000000;
format revenue dollar12.2 netincome dollar12.2 personearn dollar12.;
label personearn= "Net income per employee" revenue="Revenue($M)" rank="Global rank" netincome="Net income($M)" employee="Employee number" ;
keep rank company personearn statname stat;
array sname{4} rank revenue netincome employee;
do i=1 to dim(sname);
StatName=vlabel(sname{i});
Stat=sname{i};
if i>1 then personearn=.;
output;
end;
datalines;
1 Johnson & Johnson United States 63,747.00 12,949.00 118700
2 Pfizer United States 48,296.00 8,104.00 81800
3 GlaxoSmithKline United Kingdom 44,654.00 8,438.60 99003
4 Roche Switzerland 44,267.50 8,288.10 80080
5 Sanofi-Aventis France 42,179.00 5,636.70 98213
6 Novartis Switzerland 41,459.00 8,195.00 96717
7 AstraZeneca United Kingdom 31,601.00 6,101.00 65000
8 Abbott Laboratories United States 29,527.60 4,880.70 68838
9 Merck United States 23,850.30 7,808.40 55200
10 Wyeth United States 22,833.90 4,417.80 47426
11 Bristol-Myers Squibb United States 21,366.00 5,247.00 35000
12 Eli Lilly United States 20,378.00 -2,071.90 40500
;
run;
proc template;
define statgraph bartable;
begingraph/designwidth=600px designheight=400px;
entrytitle "Top 12 pharms as of July 2009";
entryfootnote halign=right "Sources: http://en.wikipedia.org/wiki/List_of_pharmaceutical_companies" ;
layout lattice/rows=2 rowgutter=0 rowweights=(.75 .25);
layout overlay / xaxisopts=(display=(tickvalues))
yaxisopts=(griddisplay=on linearopts=(tickvalueformat=(extractscale=true)) );
barchart x=company y=personearn / barlabel=true barlabelformat=dollar12. fillattrs=graphdata1
skin=satin outlineattrs=(color=black);
endlayout;
layout overlay / xaxisopts=(type=discrete display=none) walldisplay=(fill);
blockplot x=company block=stat / class=statName display=(outline values label) valuehalign=right repeatedvalues=true labelattrs=(size=7pt);
endlayout;
endlayout;
endgraph;
end;
run;

proc template;
define Style bartablestyle;
parent = styles.blockprint;
style GraphFonts from GraphFonts
"Fonts used in graph styles" /
'GraphTitleFont' = (", ",10pt,bold)
'GraphLabelFont' = (", ",8pt)
'GraphValueFont' = (", ",7pt)
'GraphDataFont' = (", ",7pt);
end;
run;

options nodate nonumber;
title;

ods listing close;
ods html file="bartable.html" style=bartablestyle image_dpi=300;

ods graphics /reset imagename='BarTable' imagefmt=gif;
proc sgrender data=top12 template=bartable;
run;

ods html close;
ods listing;


This post was kindly contributed by SAS Analysis - go there to comment and to read the full post.