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;
/*
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;
/*
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;
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!
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.