Hello!
I am trying to add statistics columns to a GPLOT hbar chart. In ODS using the code below I can make a nice looking hbar chart using the following code:
HBAR TESTVAR / RESPONSE=COUNT CATEGORYORDER=RESPDESC
STAT=SUM DATALABELPOS=LEFT DATALABEL ;
XAXIS LABEL='MONTHLY TOTAL' ;
I can also get the need frequency statistics by a simple PROC FREQ:
PROC FREQ DATA=PLOT ORDER=FREQ NOPRINT ;
TABLES TESTVAR/OUT=PRINT OUTCUM ;
WEIGHT COUNT;
But what I really want is to combine these two to make a chart/table like the one I created by cutting and pasting the above together (slightly different data):
Possible with GPLOT? I do not have SAS Graphics.
Thank you.
@SASplebe wrote:
I have base SAS graphics (e.g. GPLOT, etc.) but not SAS/GRAPH. Apologies, I should have been clearer in that last sentence.
Basically the rule is show a complete procedure or data step, from the first line through the Run statement.
Sometimes people ask "why is value X not showing" and then after getting the entire code we find something like:
Where somevar ne "X";
which means they specifically excluded the value.
Many statements interact and the graphic procedures may be more of that than others because you can overlay one graph on top of another and if the values are "not nice" one bit of the graph isn't seen at all.
See if this gives you enough to get further:
proc freq data=sashelp.class noprint; tables age /out=summary outcum; run; proc sgplot data=summary; HBAR age / RESPONSE=COUNT CATEGORYORDER=RESPDESC STAT=SUM DATALABELPOS=LEFT DATALABEL ; XAXIS LABEL='MONTHLY TOTAL' ; yaxistable count percent cum_freq cum_pct/ location=inside position=right ; run;
Note that I provided a data set you should have available to test code with and complete procedures.
Not really sure why you want count twice though.
Use LABEL Statements to change the text of the yaxistable labels.
I have base SAS graphics (e.g. GPLOT, etc.) but not SAS/GRAPH. Apologies, I should have been clearer in that last sentence.
@SASplebe wrote:
I have base SAS graphics (e.g. GPLOT, etc.) but not SAS/GRAPH. Apologies, I should have been clearer in that last sentence.
Basically the rule is show a complete procedure or data step, from the first line through the Run statement.
Sometimes people ask "why is value X not showing" and then after getting the entire code we find something like:
Where somevar ne "X";
which means they specifically excluded the value.
Many statements interact and the graphic procedures may be more of that than others because you can overlay one graph on top of another and if the values are "not nice" one bit of the graph isn't seen at all.
See if this gives you enough to get further:
proc freq data=sashelp.class noprint; tables age /out=summary outcum; run; proc sgplot data=summary; HBAR age / RESPONSE=COUNT CATEGORYORDER=RESPDESC STAT=SUM DATALABELPOS=LEFT DATALABEL ; XAXIS LABEL='MONTHLY TOTAL' ; yaxistable count percent cum_freq cum_pct/ location=inside position=right ; run;
Note that I provided a data set you should have available to test code with and complete procedures.
Not really sure why you want count twice though.
Use LABEL Statements to change the text of the yaxistable labels.
@SASplebe wrote:
I have base SAS graphics (e.g. GPLOT, etc.) but not SAS/GRAPH. Apologies, I should have been clearer in that last sentence.
SAS/GRAPH is GPLOT + GCHART and that family of procedures.
ODS GRAPHICS includes the SG family of graphics.
SG graphics are supported in all the newer versions since 9.3 so that's what you should be using moving forward, not GCHART or GPLOT.
Here is the report output:
Reeza, you are correct. My question/problem had to do with SGPLOT - doh!
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.