BookmarkSubscribeRSS Feed
brophymj
Quartz | Level 8

I have a list of 20-30 factors which I would like to create 4 graphs each for. Ideally I would like them in an excel file, each on a separate sheet (four graphs per sheet) but I know that's next too impossible. Exporting to powerpoint and pdf are sufficient alternatives. What I like about Excel is that you can separate each factor into its own workbook. I have started the process off using robslink.com as a reference.

My code is below (which I took from http://www.robslink.com/SAS/democd7/clin1_info.htm)

Couple of points:

  • I am trying to get one factor right so I have just created a dataset with one factor and dummy values.
  • I want 4 graphs but using the same graph here 4 times for illustrative purposes
  • In the reference above, the first few lines of code where he defines htmlvar, I'm not sure what this does.

My main challenges are:

  • In the link above he creates a bar chart with a line chart on a secondary graph and retains with a "MS excel look". I can reproduce a single graph but I need guidance on how to create 4 on a single page, that are the same size. I'm not sure what the code highlighted in red does.
  • I want the code to be flexible so that it can handle loads of different factors with different ranges of levels, some numeric (age) and some character (occupation).
  • The code highlighted in pink is not from the above link. I took it from a different source about exporting 4 graphs to a pdf. it doesn't work properly for me (graphs appear on a pdf but they don't have the format  created by robslink code and they are not fitted correctly on the page.

data my_data;
INFILE DATALINES DLM=',';
format factor level $16.;
input factor $ level $ exposure lossratio ;
datalines ;
occupation,professional,500,.44
occupation,student,1000,.55
occupation,retired,2000,.75
;
run;

data my_data; set my_data;
length htmlvar $500;
htmlvar=
'title='||quote(
  'Level: '|| trim(left(level)) ||'0D'x||
  'Vehicle Exposure Years: '|| trim(left(v01_veh_exp_years))||
  'Loss Ratio: '|| trim(left(all_LR)))||
' href="clin1_info.htm"';
run;


goptions device=png;
goptions xpixels=750 ypixels=500;
goptions noborder;

ODS LISTING CLOSE;
ODS HTML path=odsout body="&name..htm"
(title="SAS/Graph gbarline Line & Column Chart") style=sasweb;

goptions gunit=pct htitle=6 ftitle="albany amt/bold" htext=4.25 ftext="albany amt/bold";

title1 ls=1.5 "&name. - LR";
/*title2 "Classic Combination Chart";*/

pattern1 v=solid color=cx993366; 

symbol1 interpol=join width=3 value=dot height=4 color=navy; 

axis1 label=(a=90 'Exposure Years') offset=(0,2) order=(0 to 30000 by 5000) major=(h=-1) minor=none;
axis2 label=(a=90 'Loss Ratio') offset=(0,2) order=(0 to 2 by .5) major=(h=-1) minor=none;
axis3 label = none value=(angle=90) offset=(13,13) ;

device=pdfc
ftext="swissb";
ods pdf file="H:\Commercial\Fleet\Presentations\four in one.pdf" startpage=never;
ods proclabel "Four graphs on one page" ;
goptions hsize=5.20 in vsize=3.75 in;
title1;

proc gbarline data=my_data2;
goptions horigin=0in vorigin=3.99 in;
bar level / discrete
  type=sum sumvar=v01_veh_exp_years
  axis=axis1 maxis=axis3
  space=5 width=6
  html=htmlvar
  des='' name="&name" ;
plot /
  type=sum sumvar=all_LR
  axis=axis2
  html=htmlvar;
run;

quit;

proc gbarline data=my_data2;
goptions horigin=5.25;
bar level / discrete
  type=sum sumvar=v01_veh_exp_years
  axis=axis1 maxis=axis3
  space=5 width=6
  html=htmlvar
  des='' name="&name" ;
plot /
  type=sum sumvar=all_LR
  axis=axis2
  html=htmlvar;
run;

quit;


proc gbarline data=my_data2;
goptions hsize= 5.20in vsize= 3.75in device=pdfc ftext="swissb"
bar level / discrete
  type=sum sumvar=v01_veh_exp_years
  axis=axis1 maxis=axis3
  space=5 width=6
  html=htmlvar
  des='' name="&name" ;
plot /
  type=sum sumvar=all_LR
  axis=axis2
  html=htmlvar;
run;

quit;


proc gbarline data=my_data2;
goptions horigin=5.25 in;
bar level / discrete
  type=sum sumvar=v01_veh_exp_years
  axis=axis1 maxis=axis3
  space=5 width=6
  html=htmlvar
  des='' name="&name" ;
plot /
  type=sum sumvar=all_LR
  axis=axis2
  html=htmlvar;
run;

quit;

ods pdf close;

1 REPLY 1
Reeza
Super User

You need to post this under the graphics forum:

http://support.sas.com/resources/papers/proceedings12/285-2012.pdf

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 874 views
  • 0 likes
  • 2 in conversation