BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Lacona
Quartz | Level 8

Hey all,

is there any (easy) possibility to program the box and bin layout of a histogram in proc univariate?
I am using SAS university, I am not allowed to use proc sgplot, it has to be proc univariate and I am desperate, because nothing is working.

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@Lacona wrote:

Sure!
dataset ist SAShelp.gas

proc univariate data=gas noprint;
histogram/odstitle="5 histograms of nitrogen oxide" normal barlabel=percent
vaxislabel='percent' nrows=5 inheight=2.0 cfill=pink grid;
attrib _all_ label='';
title font=arial justify=center underlin=1 color=BIPPK height=4 "Histogram of Nitrogen Oxide";
class fuel;
var nox;
inset n="N:"(5.3) mean="Mean:"(5.3) / pos=ne font=arial ctext=BIB cframe=slategray height=1.8;
run;

Instruction from the teacher was, that we have to use proc univariate. He can do the layout by goption, but that is not possible in SAS university.
I would like to change the appearance of the box (height, width, color) and also of the inset and the bins. 
Pattern color=blue value=solid didn't work either.


ODS GRAPHICS options can set height and width of graph objects. If you mean "boxes" inside the graph then you may be looking at options in the histogram statement like MIDPOINTS=(middle of histogram column list values) , NENDPOINTS or NMIDPOINTS (number of end or center points).

 

Colors are controlled by the current ODS style by default. Most of the color options available in Proc Univariate Histograms I am familiar with only apply to the traditional (i.e. SAS/Graph) graphics.

View solution in original post

11 REPLIES 11
ballardw
Super User

Show the code you have attempted so far.

 

And why can you not use SGPLOT? Is that an instruction from a teacher?

Lacona
Quartz | Level 8

Sure!
dataset ist SAShelp.gas

proc univariate data=gas noprint;
histogram/odstitle="5 histograms of nitrogen oxide" normal barlabel=percent
vaxislabel='percent' nrows=5 inheight=2.0 cfill=pink grid;
attrib _all_ label='';
title font=arial justify=center underlin=1 color=BIPPK height=4 "Histogram of Nitrogen Oxide";
class fuel;
var nox;
inset n="N:"(5.3) mean="Mean:"(5.3) / pos=ne font=arial ctext=BIB cframe=slategray height=1.8;
run;

Instruction from the teacher was, that we have to use proc univariate. He can do the layout by goption, but that is not possible in SAS university.
I would like to change the appearance of the box (height, width, color) and also of the inset and the bins. 
Pattern color=blue value=solid didn't work either.

Reeza
Super User
SAS/Graph commands don't work in SAS UE. If you need SAS/Graph Academics on Demand does support it.
Lacona
Quartz | Level 8
Thank you, Reeza!
So, there is absolutely no possibility to work on the univariate histogram layout in SAS University?
Reeza
Super User
Oh no, you can, it's just not easy at all. You need to modify your templates. And I'm just realizing that most graphs now use ODS so GOPTIONS won't work as well.
SGPLOT is the correct answer here, but if that's out of scope then you're stuck modifying templates. That isn't easy and not something I recommend.
Lacona
Quartz | Level 8

Very helpful to know, that I don't have to search around for other solutions any more.
Why wouldn't you recommend to play around with the templates?
At first glance, playing around with templates doesn't seem too complicated, but maybe I am overseeing something?

Reeza
Super User
Template changes change it for all histograms. You have to remember to back it out.
I've seen people destroy their templates and have to get them back from a colleague. Also, they're hierarchical, so they can inherit from other styles so it's difficult sometimes to understand which template controls which features.
And finally, templates are designed for all possible options so you may need to make multiple changes in the code.

I guess to me this seems like a ridiculous amount of work when using SGPLOT is trivial by comparison.
Lacona
Quartz | Level 8

Thank you for the explanation. 
I will keep it in mind.

ballardw
Super User

@Lacona wrote:

Sure!
dataset ist SAShelp.gas

proc univariate data=gas noprint;
histogram/odstitle="5 histograms of nitrogen oxide" normal barlabel=percent
vaxislabel='percent' nrows=5 inheight=2.0 cfill=pink grid;
attrib _all_ label='';
title font=arial justify=center underlin=1 color=BIPPK height=4 "Histogram of Nitrogen Oxide";
class fuel;
var nox;
inset n="N:"(5.3) mean="Mean:"(5.3) / pos=ne font=arial ctext=BIB cframe=slategray height=1.8;
run;

Instruction from the teacher was, that we have to use proc univariate. He can do the layout by goption, but that is not possible in SAS university.
I would like to change the appearance of the box (height, width, color) and also of the inset and the bins. 
Pattern color=blue value=solid didn't work either.


ODS GRAPHICS options can set height and width of graph objects. If you mean "boxes" inside the graph then you may be looking at options in the histogram statement like MIDPOINTS=(middle of histogram column list values) , NENDPOINTS or NMIDPOINTS (number of end or center points).

 

Colors are controlled by the current ODS style by default. Most of the color options available in Proc Univariate Histograms I am familiar with only apply to the traditional (i.e. SAS/Graph) graphics.

Lacona
Quartz | Level 8

ods graphics on/width=4 height=6; worked perfectly! Thank you!

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 11 replies
  • 1810 views
  • 2 likes
  • 3 in conversation