Date: Wed, 20 Feb 2008 14:43:26 -0600
Reply-To: Mary <mlhoward@avalon.net>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Mary <mlhoward@AVALON.NET>
Subject: Re: how to export a nice graph or outputs into Excel or Word
Content-Type: text/plain; charset="iso-8859-1"
Jenny,
Yes, SAS certainly can, but I must say that it has a MUCH higher learning curve than using MS Excel graphics. However, one advantage is that you can save your graph as a program, and thus can rerun the program again or modify it once it is made. It also can do things like boxplots that aren't as easy in Excel.
One approach is to save SAS graphics as gif files; then these files will work like pictures that could be inserted into Excel or Word with the Insert-Picture commands or just cut and paste out of MS Paint.
Here is an example; the options apply to all graphs unless you change them. The example below uses annotate, which is like using the drawing tool in Excel to put things on top of the graph like lines or text. The colors below are listed as "CX" which is their red-green-blue number; there was a thread last week on how to find these. This should be a working program- you can try cutting and pasting it into SAS and running it (the numbers aren't the real ones :-) ).
If you set .gif files to open with MS Paint, then you can go to the directory where you create these and double-click on them to open in Paint.
-Mary
data chartset;
infile cards missover;
input pheno_type $ pct age_cat $20.;
cards;
MTRP 15.1 0 to 49
MTRP 22.2 50 to 59
MTRP 23.3 60 to 69
MTRP 24.5 70 to 79
MTRP 50.0 80 to 89
MTRP 28.1 90 to 110
AAA 22.1 0 to 49
AAA 15.1 50 to 59
AAA 30.1 60 to 69
AAA 35.1 70 to 79
AAA 40.1 80 to 89
AAA 44.1 90 to 110
Lucent 10.1 0 to 49
Lucent 20.1 50 to 59
Lucent 2.1 60 to 69
Lucent 30.1 70 to 79
Lucent 40.5 80 to 89
Lucent 60.5 90 to 110
Tubular 5.2 0 to 49
Tubular 0.0 50 to 59
Tubular 10.2 60 to 69
Tubular 20.0 70 to 79
Tubular 5.0 80 to 89
Tubular 40.0 90 to 110
;
filename graphdir 'C:\Work_Activities\graphs';
goptions device=gif hsize=7 vsize=4.1
ftitle="arial/bold/italic"
ftext="arial/italic"
ctext=navy
fontres=presentation
htitle=14pt
htext=10pt
gsfname=graphdir
gsfmode=replace
cback=cornsilk
noborder;
pattern1 color="cxff0000";
pattern2 color="cxffff00";
pattern3 color="cx00ff00";
pattern4 color="cx0000ff";
axis1 label=(height=2 justify=center ' ') value=(' ' ' ' ' ' ' ');
axis2 label=(height=2 justify=center) value=(height=2 angle=45);
axis3 label=(angle=90 h=.15in)
order=(0 to 60 by 10);
title h=.25in f="arial" c=black " ";
title2 h=.25in f="arial" c=black " ";
footnote h=.175in f="arial" c=black j=l " " j=r "Feb. 2008 ";
legend1 position=(bottom) across=4 shape=bar(2,.5) label=none frame;
data work.other_anno;
length function style color $ 8 text $ 25;
retain hsys xsys ysys '3';
/* create observation to draw the title */
function='label'; x=20; y=95;
text="Phenotype Percents by Age Category;";
style="swissb"; color="cx0033FF";
output;
function='move'; x=10; y=90; output;
function='draw'; x=90; y=90; size=.6; line=1;
color="cx0033FF"; output;
function='move'; x=0; y=100; output;
function='draw'; x=100; y=100; size=1.0; line=1;
color="cxCCCCCC"; output;
function='draw'; x=100; y=0; size=1.0; line=1;
color="cxCCCCCC"; output;
function='draw'; x=0; y=0; size=1.0; line=1;
color="cxCCCCCC"; output;
function='draw'; x=0; y=100; size=1.0; line=1;
color="cxCCCCCC"; output;
run;
proc gchart data=chartset anno=work.other_anno;
format pct 5.1;
vbar pheno_type/
discrete
ref=10 20 30 40 50 60
minor=0
group=age_cat
subgroup=pheno_type
patternid=subgroup
sumvar=pct
maxis=axis1
gaxis=axis2
raxis=axis3
cframe="cxCCFFFF"
space=0
name='plot1';
run;
quit;
----- Original Message -----
From: Jenny Zhang
To: SAS-L@LISTSERV.UGA.EDU
Sent: Sunday, February 17, 2008 9:28 PM
Subject: how to export a nice graph or outputs into Excel or Word
Hi SAS helpers,
I have two queries.
1. Can SAS produce nice graphs? If yes, how can I export into Excel or
Word?
2. Can I export output such as tables into Excel or Word? If yes, can
you pls provide the code?
Many thanks
Jenny