BookmarkSubscribeRSS Feed
echoli
Obsidian | Level 7

Hi All,

 

Can I run a dynamic proc template of histogram but with different groups? I have a variable, it has three groups, I can run with different groups in boxplot, but how can I edit histogram part by groups? Below is the code I use and the output.

 

proc template;
define statgraph mygraphs.dynamics;
begingraph;
layout lattice / columns = 1 rows = 2
columndatarange = union
rowgutter = 2px;
mvar SYSDATE9 SCALE;
nmvar BINS;
dynamic VAR VARLABEL;
entrytitle 'Histogram of ' VAR;
entrytitle 'with Normal Distribution';
columnaxes;
columnaxis / label = 'var';
endcolumnaxes;
layout overlay / xaxisopts=(label=VARLABEL)
yaxisopts = (offsetmin = .03);
histogram VAR / display = standard;
class group;
densityplot VAR / normal( );
fringeplot var;
endlayout;
boxplot y = var x = group/ orient = horizontal;
endlayout;
entryfootnote halign=right "Created: " SYSDATE9 / textattrs=GraphValueText;
endgraph;
end;
run;

%let scale=percent;
proc sgrender data=combine_1 template='mygraphs.dynamics';
dynamic var='P_SCALE_SCORE_PHYSICAL_FUNCTI' varlabel='P_SCALE_SCORE_PHYSICAL_FUNCTI';
run;

 

proc template.png

thanks,

C

5 REPLIES 5
ballardw
Super User

Are you wanting to create histogram for the same groups as in your box plot?

echoli
Obsidian | Level 7

Yes, the same groups. I tried to use class below histogram statement, but it doesn't work. Any idea?

 

thanks,

C

DanH_sas
SAS Super FREQ

We added GROUP support to histograms in SAS 9.4. What version of SAS are you running?

echoli
Obsidian | Level 7

I use SAS 9.4, but I didn't find group option. I searched SAS 9.3, didn't find helpful link in 9.4. Could you give me a link or some idea?

 

Thanks,

C

Mombi
Calcite | Level 5

Hi there!

@echoli, in the end, did you find a solution? I know it has been a while since the last post but I am facing the exact same problem and don't know how to do so if you have a hint, I would be very interested 🙂
P.S.: Please be kind, I am a SAS newbie 🐥

 

sas-innovate-2024.png

Today is the last day to save with the early bird rate! Register today for just $695 - $100 off the standard rate.

 

Plus, pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 5 replies
  • 2407 views
  • 0 likes
  • 4 in conversation