BookmarkSubscribeRSS Feed
zhangda
Fluorite | Level 6

Hello, 

 

I am coding to generate a PPT file in SAS9.4, where I want the three graphs all together within one silde,  from them, two are in the first row, and one in the second row. but why the result looks too bad, the graphs are all deformed, would you please help out?

Thanks!

 

 


goptions reset=all cback=white border htitle=12pt htext=10pt;

data ds1;
input year $ mid $ resp exp rev;
datalines;
null d_2016 0.45 0.45 0.35
null d_2015 0.35 0.45 0.35
s_300 d_2016 0.65 0.65 0.55
s_300 d_2015 0.55 0.65 0.55
s_640 d_2016 0.42 0.42 0.65
s_640 d_2015 0.65 0.42 0.65
s_670 d_2016 0.35 0.35 0.75
s_670 d_2015 0.75 0.35 0.75
s_700 d_2016 0.83 0.83 0.47
s_700 d_2015 0.47 0.83 0.47
s_730 d_2016 0.48 0.48 0.58
s_730 d_2015 0.58 0.48 0.58
s_760 d_2016 0.67 0.67 0.69
s_760 d_2015 0.69 0.67 0.69
;
run;

data ds1_new;
input year $ mid $ resp exp rev;
datalines;
null d_2016 0.45 0.45 0.89
null d_2015 0.35 0.45 0.89
s_300 d_2016 0.65 0.65 0.45
s_300 d_2015 0.55 0.65 0.45
s_640 d_2016 0.42 0.42 0.65
s_640 d_2015 0.65 0.42 0.65
s_670 d_2016 0.35 0.35 0.75
s_670 d_2015 0.75 0.35 0.75
s_700 d_2016 0.83 0.83 0.47
s_700 d_2015 0.47 0.83 0.47
s_730 d_2016 0.48 0.48 0.58
s_730 d_2015 0.58 0.48 0.58
s_760 d_2016 0.67 0.67 0.69
s_760 d_2015 0.69 0.67 0.69
;
run;

data ds1_old;
input year $ mid $ resp exp rev;
datalines;
null d_2016 0.45 0.45 0.77
null d_2015 0.35 0.45 0.77
s_300 d_2016 0.65 0.65 0.88
s_300 d_2015 0.55 0.65 0.88
s_640 d_2016 0.42 0.42 0.99
s_640 d_2015 0.65 0.42 0.99
s_670 d_2016 0.35 0.35 0.75
s_670 d_2015 0.75 0.35 0.75
s_700 d_2016 0.83 0.83 0.47
s_700 d_2015 0.47 0.83 0.47
s_730 d_2016 0.48 0.48 0.58
s_730 d_2015 0.58 0.48 0.58
s_760 d_2016 0.67 0.67 0.69
s_760 d_2015 0.69 0.67 0.69
;
run;

%macro threegraph ( from, to, title );

data &to.;
set &from.;
n=_n_;
run;

data _null_;
set &to. end=eof;
if eof then call symput('skip',left(n));
run;

proc sort;
by year mid;
run;

data anno;
set &to.;
by year mid;
length function color $8 text $20 style $ 20;

/* Populate the table */
if first.year then do;
function='move'; xsys='2'; ysys='1';
midpoint=mid; group=year; y=0;
output;
function='cntl2txt'; output;
function='label'; xsys='A'; ysys='3';
x=+2; y=13;
text=trim(left(put(exp,8.1)));
color='black'; position='+'; when='a';
output;
function='move'; xsys='2'; ysys='1';
midpoint=mid; group=year; y=0;
output;
function='cntl2txt'; output;
function='label'; xsys='A'; ysys='3';
x=+2; y=9;
text=trim(left(put(rev,8.1)));
color='black'; position='+'; when='a';
output;
end;

/* Generate the table frame */
function='move'; xsys='3'; ysys='3';
x=3; y=6;
output;
function='bar'; xsys='1'; ysys='3';
x=100; y=15;
style='empty'; color='black'; line=0;
output;

/* Generate the row headers */
function='label'; xsys='3'; ysys='3';
style='marker'; text='U'; color='cx7c95ca';
x=3; y=13; position='6';
output;
function='label'; xsys='3'; ysys='3';
style='"Albany AMT"'; text='d_2015'; color='black';
x=6; y=13; position='6';
output;
function='label'; xsys='3'; ysys='3';
style='marker'; text='U'; color='cxde7e6f';
x=3; y=8.5; position='6';
output;
function='label'; xsys='3'; ysys='3';
style='"Albany AMT"'; text='d_2016'; color='black';
x=6; y=9; position='6';
output;

/* Generate the vertical lines in the table */
function='move'; xsys='1'; ysys='1';
x=0; y=0;
output;
function='draw'; xsys='1'; ysys='3';
x=0; y=6;
line=1; color='black';
output;
function='move'; xsys='1'; ysys='1';
x=100; y=0;
output;
function='draw'; xsys='1'; ysys='3';
x=100; y=6;
line=1; color='black';
output;

if first.year and n ^=&skip then do;
function='move'; xsys='2'; ysys='1';
midpoint=mid; y=0; group=year;
output;
function='move'; xsys='A'; ysys='1';
x=+15.5; x=+8; y=0;
output;
function='draw'; xsys='A'; ysys='3';
x=+0; y=6;
color='black'; line=1;
output;
end;

/* Generate the horizontal line in the table */
function='move'; xsys='3'; ysys='3';
x=3; y=10.5;
output;
function='draw'; xsys='1'; ysys='3';
x=100; y=10.5;
line=1; color='black';
output;
run;

title1 &title. ;

axis1 label=(a=90 'Percentegy')
order=(0 to 1 by 0.1)
minor=none;

axis2 label=none
value=none
origin=(20pct,22pct)
offset=(4pct,4pct);

axis3 label=none;

footnote1 'Fiscal Year';
footnote2 h=.5 ' ';

pattern1 value=solid color=cx7c95ca;
pattern2 value=solid color=cxde7e6f;

proc gchart data=&to.;
vbar mid / sumvar=resp group=year
coutline=black patternid=midpoint
space=0 gspace=0 width=5
cframe=ltgray autoref clipref
raxis=axis1 maxis=axis2 gaxis=axis3
annotate=anno;
run;
quit;

%mend;
%threegraph (ds1, ds2 , "First distribution" );
%threegraph (ds1_new, ds2_new , "New distri." );
%threegraph (ds1_old, ds2_old , "Old distri.");

 

 

title "&premon. Distribution for All Loan Products by Winning FICO" HEIGHT=12pt ;


ods powerpoint file=' C/SASMAIN/MINE/PPT.pptx ' layout=threecontent(advance=proc);
/*ods graphics / width=4.5in height=4in; */
/*ods layout gridded columns=2 rows=2 ; */
/* ods region; */
proc gchart data=ds2;
vbar mid / sumvar=resp group=year
coutline=black patternid=midpoint
space=0 gspace=0 width=5
cframe=ltgray autoref clipref
raxis=axis1 maxis=axis2 gaxis=axis3
annotate=anno;
run;
quit;

proc gchart data=ds2_new;
vbar mid / sumvar=resp group=year
coutline=black patternid=midpoint
space=0 gspace=0 width=5
cframe=ltgray autoref clipref
raxis=axis1 maxis=axis2 gaxis=axis3
annotate=anno;
run;
quit;

proc gchart data=ds2_old;
vbar mid / sumvar=resp group=year
coutline=black patternid=midpoint
space=0 gspace=0 width=5
cframe=ltgray autoref clipref
raxis=axis1 maxis=axis2 gaxis=axis3
annotate=anno;
run;
quit;


/*ods layout end; */
ods powerpoint close;

 

1 REPLY 1
ballardw
Super User

The older SAS device based graphics such as produced by GCHART are not idea candidates as the graphs are intended to go to a specific device and the layout is often not going to appear well in Powerpoint.

 

I suspect that some work with Proc SGPANEL that allows you to create similar graphs and have the layout specified into a number of columns and rows would work better as that would send a single graph to the PPT.

You may have to add a variable to your data sets to indicate which panel to display the values in and for use in a PANELBY statement but that should be easy when combining all the data into one set.

 

I'm not going to make any specific suggestions as I am not sure exactly what you want the output to look like.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 1200 views
  • 0 likes
  • 2 in conversation