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 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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