The top12 pharms

May 19, 2010

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;
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);
if i>1 then personearn=.;
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
proc template;
define statgraph bartable;
begingraph/designwidth=600px designheight=400px;
entrytitle "Top 12 pharms as of July 2009";
entryfootnote halign=right "Sources:" ;
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);
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);

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);

options nodate nonumber;

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;

ods html close;
ods listing;

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

Tags: , ,

Welcome! offers news and tutorials about the various SAS® software packages, contributed by bloggers. You are welcome to subscribe to e-mail updates, or add your SAS-blog to the site.


Dear readers, proc-x is looking for sponsors who would be willing to support the site in exchange for banner ads in the right sidebar of the site. If you are interested, please e-mail me at:
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration.