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

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,

 SGPanel44.png
and 
Analysis Variable : sum_appln_hrmDivision N Obs N Mean Std Dev Minimum MaximumA 36B 261C 235D 8309E 480F 273G 145H 262I 1677J 8
3620.916666750.35779131.0000000264.0000000
26120.888888956.80668221.0000000542.0000000
23528.702127791.08714601.00000001042.00
8309206.99590811524.661.000000070641.00
48066.8791667336.30232011.00000004051.00
27340.6483516227.85604201.00000002909.00
14514.917241466.64181861.0000000754.0000000
26226.7442748128.87514921.00000001630.00
1677133.68336312142.311.000000071910.00
8186.1250000515.94502411.00000001463.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. 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
NOVARNAME on the PANELBY statement.
In general, check the docs for the statements used and look at the options to see if what you want exists. Since those titles are part of the BY group, I checked the PANELBY statement and found it has the NOVARNAME option (which I didn't know about before this).

https://documentation.sas.com/?docsetId=grstatproc&docsetTarget=n0wqazuv6959fnn1fask7mi68lla.htm&doc...

View solution in original post

3 REPLIES 3
Reeza
Super User

Use an Inset. 

See the example here which generates this, you can customize it.

insetsgpanel

https://documentation.sas.com/?docsetId=grstatproc&docsetTarget=n19gxtzyuf79t3n16g5v26b73ckv.htm&doc...

 


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

 SGPanel44.png
and 
Analysis 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. 


 

Alexxxxxxx
Pyrite | Level 9

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,

SGPanel24.png 

 

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.

 

Reeza
Super User
NOVARNAME on the PANELBY statement.
In general, check the docs for the statements used and look at the options to see if what you want exists. Since those titles are part of the BY group, I checked the PANELBY statement and found it has the NOVARNAME option (which I didn't know about before this).

https://documentation.sas.com/?docsetId=grstatproc&docsetTarget=n0wqazuv6959fnn1fask7mi68lla.htm&doc...

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 3 replies
  • 813 views
  • 0 likes
  • 2 in conversation