I am trying to create a chart with 2 sets of data being displayed. I have created the 2 charts separately. One is a interleave vertical bar chart and the other a simple line plot. I have managed to compile one dataset that contains all the information for the 2 charts. I cannot figure out how to use Proc GPLOT to overlay the 2 sets of information. Currently I am creating this chart in excel. It would really save me a lot of time if I could create in SAS. Attached is a document that has screen shots of the 2 separate charts that I have created in EG using the Graph Task and the one manual chart showing both data representations that I am creating manually in excel. I need help figureing out how create one chart with both data representations using SAS EG 7.1.
I have taken a sample of GPLOT and tried to combine the code I get from the tasks in eg to create one chart but I keep getting errors. I am also including the task code for each of the individual charts I have created with EG.
Is there any other information I can provide to assist with pulling this all together. I have been working on this for days and am not getting anywhere. Any assistance would be greatly appreciated.
/* -------------------------------------------------------------------
Code generated by SAS Task
Interleave Bar Chart - Avg Days Open by Tier
Input Data: SASApp:UAT.CH2_DATA
Server: SASApp
------------------------------------------------------------------- */
%_eg_conditional_dropds(WORK.SORTTempTableSorted);
/* -------------------------------------------------------------------
Sort data set SASApp:UAT.CH2_DATA
------------------------------------------------------------------- */
PROC SQL;
CREATE VIEW WORK.SORTTempTableSorted AS
SELECT T.type, T.tier, T.avg_days_open, T.lob
FROM UAT.CH2_DATA as T
;
QUIT;
%_sas_pushchartsize(400,300);
PATTERN1 COLOR=CX333399;
PATTERN2 COLOR=CX969696;
PATTERN3 COLOR = _STYLE_;
PATTERN4 COLOR = _STYLE_;
PATTERN5 COLOR = _STYLE_;
PATTERN6 COLOR = _STYLE_;
PATTERN7 COLOR=CX333399;
PATTERN8 COLOR=CX969696;
PATTERN9 COLOR = _STYLE_;
PATTERN10 COLOR = _STYLE_;
PATTERN11 COLOR = _STYLE_;
PATTERN12 COLOR = _STYLE_;
Axis1
STYLE=1
WIDTH=1
MINOR=
(NUMBER=4
)
LABEL=( FONT='/b' "Avg. Days Open")
;
Axis2
STYLE=1
WIDTH=1
LABEL=NONE
VALUE=NONE
;
Axis3
LABEL=NONE
;
TITLE;
FOOTNOTE;
PROC GCHART DATA=WORK.SORTTempTableSorted
;
VBAR
type
/
SUMVAR=avg_days_open
GROUP=tier
CLIPREF
SPACE=0
FRAME TYPE=SUM
COUTLINE=BLACK
RAXIS=AXIS1
MAXIS=AXIS2
GAXIS=AXIS3
PATTERNID=MIDPOINT
DES=' '
LREF=1
CREF=CX969696
AUTOREF
;
BY lob;
/* -------------------------------------------------------------------
End of task code
------------------------------------------------------------------- */
RUN; QUIT;
%_eg_conditional_dropds(WORK.SORTTempTableSorted);
TITLE; FOOTNOTE;
%_sas_popchartsize;
PATTERN1;
PATTERN2;
PATTERN7;
PATTERN8;
/* -------------------------------------------------------------------
Code generated by SAS Task
Line Plot Chart Code - #Open Issues
Server: SASApp
------------------------------------------------------------------- */
%_eg_conditional_dropds(WORK.SORTTempTableSorted);
/* -------------------------------------------------------------------
Sort data set SASApp:UAT.CH2_DATA
------------------------------------------------------------------- */
PROC SQL;
CREATE VIEW WORK.SORTTempTableSorted AS
SELECT T.type, T.tier, T.avg_days_open, T.lob
FROM UAT.CH2_DATA as T
;
QUIT;
%_sas_pushchartsize(400,300);
PATTERN1 COLOR=CX333399;
PATTERN2 COLOR=CX969696;
PATTERN3 COLOR = _STYLE_;
PATTERN4 COLOR = _STYLE_;
PATTERN5 COLOR = _STYLE_;
PATTERN6 COLOR = _STYLE_;
PATTERN7 COLOR=CX333399;
PATTERN8 COLOR=CX969696;
PATTERN9 COLOR = _STYLE_;
PATTERN10 COLOR = _STYLE_;
PATTERN11 COLOR = _STYLE_;
PATTERN12 COLOR = _STYLE_;
Axis1
STYLE=1
WIDTH=1
MINOR=
(NUMBER=4
)
LABEL=( FONT='/b' "Avg. Days Open")
;
Axis2
STYLE=1
WIDTH=1
LABEL=NONE
VALUE=NONE
;
Axis3
LABEL=NONE
;
TITLE;
FOOTNOTE;
PROC GCHART DATA=WORK.SORTTempTableSorted
;
VBAR
type
/
SUMVAR=avg_days_open
GROUP=tier
CLIPREF
SPACE=0
FRAME TYPE=SUM
COUTLINE=BLACK
RAXIS=AXIS1
MAXIS=AXIS2
GAXIS=AXIS3
PATTERNID=MIDPOINT
DES=' '
LREF=1
CREF=CX969696
AUTOREF
;
BY lob;
/* -------------------------------------------------------------------
End of task code
------------------------------------------------------------------- */
RUN; QUIT;
%_eg_conditional_dropds(WORK.SORTTempTableSorted);
TITLE; FOOTNOTE;
%_sas_popchartsize;
PATTERN1;
PATTERN2;
PATTERN7;
PATTERN8;
You need to provide sample data.
I would reccommend SGPLOT instead of current plots.
If you want to stick with the device based graphics look at Proc GBARLINE, not the most flexible.
From the online help for SGPLOT here is an example with SGPLOT
proc sgplot data=sashelp.stocks (where=(date >= "01jan2000"d
and date <= "01jan2001"d
and stock = "IBM"));
title "Stock Volume vs. Close";
/*Create the bar chart.
RESPONSE= specifies the response variable.*/
vbar date / response=volume;
/*Create the line chart.
RESPONSE= specifies the response variable.
Y2AXIS assigns the chart to the Y2 axis. */
vline date / response=close y2axis;
run;
YAXIS, XAXIS, Y2AXIS and X2AXIS are used in stead of Axis statements and colors default to style definitions instead of pattern statements.
You really should post it at ODS Graphic.
proc freq data=sashelp.class noprint;
table sex*age/list out=have;
run;
proc sql;
create table temp as
select age as new_age,count(*)/(select count(*) from sashelp.class) as per format=percent7.2
from sashelp.class
group by age;
quit;
data have;
merge have temp;
run;
proc sgplot data=have;
vbarparm category=age response=count/ group=sex groupdisplay=cluster name='a';
series x=new_age y=per/ lineattrs=graphdata3(thickness=8) markers
transparency=0.4 y2axis name='b'
markerattrs=graphdata3(symbol=circlefilled size=18) filledoutlinedmarkers
markerfillattrs=(color=white) markeroutlineattrs=graphdata3(thickness=4) ;
y2axis labelattrs=graphdata3 valueattrs=graphdata3;
keylegend 'a' 'b' / title=' ';
run;
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!
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.