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

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
ods select none;
ods select histogram;
proc univariate data=sashelp.heart;
class status sex;
var weight;
histogram weight/normal kernel;
run;
ods select all;

View solution in original post

9 REPLIES 9
Norman21
Lapis Lazuli | Level 10

This might help:

 

https://blogs.sas.com/content/iml/2016/03/09/comparative-panel-overlay-histograms-sas.html

Norman.
SAS 9.4 (TS1M6) X64_10PRO WIN 10.0.17763 Workstation

PeterClemmensen
Tourmaline | Level 20

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;
NKormanik
Barite | Level 11

@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.

Ksharp
Super User
ods select none;
ods select histogram;
proc univariate data=sashelp.heart;
class status sex;
var weight;
histogram weight/normal kernel;
run;
ods select all;
NKormanik
Barite | Level 11

@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;
Ksharp
Super User
If you need producing a 2x2 panel , you need TWO class variables ,both have TWO levels .

class Indicator1 Indicator2 ;
NKormanik
Barite | Level 11

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!

 

Ksharp
Super User

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;

NKormanik
Barite | Level 11

You da man, @Ksharp , as usual.

Thanks!

 

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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.

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
  • 9 replies
  • 1539 views
  • 9 likes
  • 4 in conversation