Four different datasets, but similar:
A, B, C, D
Contents of each one:
Parameter
Count
I'd like to create a graphic with four histograms, one for each dataset.
A B
C D
I need to then save the graphic:
ABCD.png
Any thoughts appreciated.
Nicholas Kormanik
ods select none;
ods select histogram;
proc univariate data=sashelp.heart;
class status sex;
var weight;
histogram weight/normal kernel;
run;
ods select all;
This might help:
https://blogs.sas.com/content/iml/2016/03/09/comparative-panel-overlay-histograms-sas.html
Concatenate the data sets into one, use the Indsname Option and Proc Panel.
See if you can use this as a template.
data want;
set A B C D indsname = ds;
run;
proc sgpanel data = want;
panelby ds / columns = 2;
histogram Count;
run;
@PeterClemmensen "Indsname" was crucial in solving the issue at hand. @Rick_SAS wrote a blog post clearly showing how. Greatly appreciate his continued help here.
ods select none;
ods select histogram;
proc univariate data=sashelp.heart;
class status sex;
var weight;
histogram weight/normal kernel;
run;
ods select all;
@Ksharp Turns out that 2x2 is not necessary. 1x4 looks fine. So sticking for the time being with Proc Univariate....
ods graphics on / height=1920px width=3413px ;
data sas_1.i_20201;
set
sas_1.sum_i_20201_long_gt
sas_1.sum_i_20201_long_lt
sas_1.sum_i_20201_short_gt
sas_1.sum_i_20201_short_lt
;
run;
ods listing gpath='c:\3\';
ods graphics / imagename="i_20201_" imagefmt=png;
proc univariate data=sas_1.i_20201;
freq Count;
var Parameter;
class Indicator (order=data);
histogram Parameter /
nrows = 4
barlabel=count
href=0
kernel (c = 0.25 0.50 0.75 1.00
l = 1 20 2 34
noprint)
odstitle = "i_20201";
inset
n="n:" (8.0)
max="max:" (8.2)
q3="q3:" (8.2)
mode="mode:" (8.2)
median="median:" (8.2)
mean="mean:" (8.2)
q1="q1:" (8.2)
min="min:" (8.2)
std="std:" (8.2)
/
pos = nw
cfill=blank
;
run;
One final question related to this post:
I really don't need any of the output except the saved .png files.
Is there a way to accomplish this? My hunch is via ODS, but not sure.
Again, no output except the histogram graphics file production.
Thanks to all of you!
Sure. Here is an example.
ods select none;
ods select histogram;
ods listing gpath='c:\temp\';
ods graphics /reset=index imagename="i_20201_" imagefmt=png;
proc univariate data=sashelp.heart;
class status sex;
var weight;
histogram weight/normal kernel;
run;
ods select all;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.