BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
David17
Fluorite | Level 6

I am trying to create a sgpanel of hbox, organized by 4 physician categories, with boxes for each physician specialty.  Each specialty belongs to a single category.  So specgp="Family Medicine" only belongs to the SpecCat="General."   When I try to create this, SAS tries to put all the specialty options in for all the category panels, when the other 3 categories have no data for that specialty.  I want to suppress the output in those other panels where there's no data.

Also, the number of specialties varies by category.  "General" has 3 specialties while "Internal" has 7.  I'd like the height of each panel to adjust depending on how many specialties there are.  I'd like a different reference line for each panel.  This code puts all 4 reference lines in all 4 panels.  

I created some test data with 2 categories and 5 specialties to show what I mean.  Thanks in advance.  I'm using SAS 9.4.

data phystest;
input speccat $ specgp $ out;
datalines;
General Family 0.2
General Family 0.3
General Family 0
General Family -0.2
General Pediatric 0.1
General Pediatric -0.1
General Pediatric -0.2
General Pediatric -0.5
Internal Surgery -0.5
Internal Surgery -0.7
Internal Surgery -0.8
Internal Surgery -0.9
Internal Cardiology 1.2
Internal Cardiology 1.4
Internal Cardiology 1.7
Internal Cardiology 1.3
Internal Radiology 0.7
Internal Radiology 0.5
Internal Radiology 0.2
Internal Radiology 0.9
Internal Radiology 1.7
;
proc sgpanel data=phystest noautolegend;
   panelby speccat / rows=2;
   refline 0.25 -0.25 / axis=x label lineattrs=(color=GREEN);
   hbox out / category=specgp ;
   colaxis grid minor minorcount=4 
   min=-1 max=2 gridattrs=(color=LIGR);
   label speccat="Category" specgp="Specialty";
run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
/*
That is not an easy task.
Here is an example.
*/
data phystest;
infile datalines truncover;
input speccat $ specgp $ out ref ;
datalines;
General Family 0.2  0.25
General Family 0.3
General Family 0
General Family -0.2
General Pediatric 0.1
General Pediatric -0.1
General Pediatric -0.2
General Pediatric -0.5
Internal Surgery -0.5  -0.25
Internal Surgery -0.7
Internal Surgery -0.8
Internal Surgery -0.9
Internal Cardiology 1.2
Internal Cardiology 1.4
Internal Cardiology 1.7
Internal Cardiology 1.3
Internal Radiology 0.7
Internal Radiology 0.5
Internal Radiology 0.2
Internal Radiology 0.9
Internal Radiology 1.7
;

proc sgpanel data=phystest  noautolegend ;
   panelby speccat / rows=2 uniscale=column PROPORTIONAL nowall;
   hbox out / category=specgp ;
   colaxis grid minor minorcount=4 
   min=-1 max=2 gridattrs=(color=LIGR);
   label speccat="Category" specgp="Specialty";
   refline ref/axis=x lineattrs=(color=green) label;
run;


Ksharp_0-1691149658328.png

 

View solution in original post

2 REPLIES 2
Ksharp
Super User
/*
That is not an easy task.
Here is an example.
*/
data phystest;
infile datalines truncover;
input speccat $ specgp $ out ref ;
datalines;
General Family 0.2  0.25
General Family 0.3
General Family 0
General Family -0.2
General Pediatric 0.1
General Pediatric -0.1
General Pediatric -0.2
General Pediatric -0.5
Internal Surgery -0.5  -0.25
Internal Surgery -0.7
Internal Surgery -0.8
Internal Surgery -0.9
Internal Cardiology 1.2
Internal Cardiology 1.4
Internal Cardiology 1.7
Internal Cardiology 1.3
Internal Radiology 0.7
Internal Radiology 0.5
Internal Radiology 0.2
Internal Radiology 0.9
Internal Radiology 1.7
;

proc sgpanel data=phystest  noautolegend ;
   panelby speccat / rows=2 uniscale=column PROPORTIONAL nowall;
   hbox out / category=specgp ;
   colaxis grid minor minorcount=4 
   min=-1 max=2 gridattrs=(color=LIGR);
   label speccat="Category" specgp="Specialty";
   refline ref/axis=x lineattrs=(color=green) label;
run;


Ksharp_0-1691149658328.png

 

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 597 views
  • 1 like
  • 2 in conversation