Hi all,
I use the following code to create a list of histograms and a distribution table
title 'The distribution of patent applied by companies in different industries';
proc sgpanel data=step7.Data_pat_matchresult93_21;
panelby Division /
uniscale=row;
histogram sum_appln_hrm;
density sum_appln_hrm;
LABEL sum_appln_hrm='number of patents applied by the company';
run;
proc means data=step7.Data_pat_matchresult93_21;
class Division;
var sum_appln_hrm;
run;
the following are two histograms,
36 | 20.9166667 | 50.3577913 | 1.0000000 | 264.0000000 |
261 | 20.8888889 | 56.8066822 | 1.0000000 | 542.0000000 |
235 | 28.7021277 | 91.0871460 | 1.0000000 | 1042.00 |
8309 | 206.9959081 | 1524.66 | 1.0000000 | 70641.00 |
480 | 66.8791667 | 336.3023201 | 1.0000000 | 4051.00 |
273 | 40.6483516 | 227.8560420 | 1.0000000 | 2909.00 |
145 | 14.9172414 | 66.6418186 | 1.0000000 | 754.0000000 |
262 | 26.7442748 | 128.8751492 | 1.0000000 | 1630.00 |
1677 | 133.6833631 | 2142.31 | 1.0000000 | 71910.00 |
8 | 186.1250000 | 515.9450241 | 1.0000000 | 1463.00 |
is there any method to put them together? I expect to put the 'N obs', 'N', 'Mean', 'Min' and 'Max' on the top right of each histogram.
Could you pelase give me some suggestions about this?
thanks in advance.
Use an Inset.
See the example here which generates this, you can customize it.
@Alexxxxxxx wrote:
Hi all,
I use the following code to create a list of
histograms and a distribution table
title 'The distribution of patent applied by companies in different industries'; proc sgpanel data=step7.Data_pat_matchresult93_21; panelby Division / uniscale=row; histogram sum_appln_hrm; density sum_appln_hrm; LABEL sum_appln_hrm='number of patents applied by the company'; run; proc means data=step7.Data_pat_matchresult93_21; class Division; var sum_appln_hrm; run;
the following are two
histograms,
andAnalysis Variable : sum_appln_hrmDivision N Obs N Mean Std Dev Minimum MaximumA 36B 261C 235D 8309E 480F 273G 145H 262I 1677J 8
36 20.9166667 50.3577913 1.0000000 264.0000000 261 20.8888889 56.8066822 1.0000000 542.0000000 235 28.7021277 91.0871460 1.0000000 1042.00 8309 206.9959081 1524.66 1.0000000 70641.00 480 66.8791667 336.3023201 1.0000000 4051.00 273 40.6483516 227.8560420 1.0000000 2909.00 145 14.9172414 66.6418186 1.0000000 754.0000000 262 26.7442748 128.8751492 1.0000000 1630.00 1677 133.6833631 2142.31 1.0000000 71910.00 8 186.1250000 515.9450241 1.0000000 1463.00
is there any method to put them together? I expect to put the 'N obs', 'N', 'Mean', 'Min' and 'Max' on the top right of each
histogram.
Could you pelase give me some suggestions about this?
thanks in advance.
Dear @Reeza ,
Thanks for your advice.
appreciate your link, I use the following code, which works well.
proc means data=step7.Data_pat_matchresult93_21 nway;
class Division_description;
var sum_appln_hrm;
output out=Data_pat N(sum_appln_hrm)=N_obs
mean(sum_appln_hrm)=Mean_appln Min(sum_appln_hrm)=Min_appln
Max(sum_appln_hrm)=Max_appln;
run;
proc sort data=step7.Data_pat_matchresult93_21 out=Data_pat1;
by Division_description;
run;
data merged;
merge Data_pat Data_pat1;
by Division_description;
label N_obs = "N obs";
label Mean_appln = "Mean";
label Min_appln = "Min";
label Max_appln = "Max";
run;
proc sgpanel data=merged;
panelby Division_description /
uniscale=row;
histogram sum_appln_hrm;
density sum_appln_hrm;
inset N_obs Mean_appln Min_appln Max_appln/
position=topright textattrs=(style=italic) ;
label sum_appln_hrm='Number of applications';
run;
and get the result as below,
However, the title of each histogram cannot show the total strings. Could you please give me some suggestions about this?
for 'Division_description=WHOLESALE TRADE' I expect to only have 'WHOLESALE TRADE' for each division histogram
is that possible?
thanks in advance.
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.