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

Is there a sgpanel, hbar tooltip override feature similar to the series plot tooltip override feature in SAS 9.2?

Code without the tooltip feature is below:


/*ROLENAME=(Year=FOUR_DIGIT_YEAR Level=degree_level)

TIP=(Year Level Y) tiplabel=(Year='Academic Term' Y='Students Enrolled' Level ='Level') */;

proc sql noprint;

CREATE TABLE enrollment (

  FOUR_DIGIT_YEAR varchar(50),

  STUDENTS_ENROLLED int,

  residency_desc varchar(50),

  degree_level varchar(50)

);tooltip.png

/*panel one data*/

INSERT INTO enrollment

  (FOUR_DIGIT_YEAR, STUDENTS_ENROLLED, residency_desc, degree_level)

VALUES

  ('2001', 234, '1', 'Bac');

INSERT INTO enrollment

  (FOUR_DIGIT_YEAR, STUDENTS_ENROLLED, residency_desc, degree_level)

VALUES

  ('2002', 345, '1', 'Bac');

INSERT INTO enrollment

  (FOUR_DIGIT_YEAR, STUDENTS_ENROLLED, residency_desc, degree_level)

VALUES

  ('2002', 584, '1', 'Master');

/*panel two data*/

INSERT INTO enrollment

  (FOUR_DIGIT_YEAR, STUDENTS_ENROLLED, residency_desc, degree_level)

VALUES

  ('2001', 465, '2', 'Bac');

INSERT INTO enrollment

  (FOUR_DIGIT_YEAR, STUDENTS_ENROLLED, residency_desc, degree_level)

VALUES

  ('2002', 344, '2', 'Bac');

INSERT INTO enrollment

  (FOUR_DIGIT_YEAR, STUDENTS_ENROLLED, residency_desc, degree_level)

VALUES

  ('2002', 200, '2', 'Master');

quit;

proc sgpanel data=enrollment;

  panelby residency_desc/ novarname uniscale=row  layout=columnlattice;

  rowaxis;

  hbar FOUR_DIGIT_YEAR / response=STUDENTS_ENROLLED stat=sum group=degree_level

  /*ROLENAME=(Year=FOUR_DIGIT_YEAR Level=degree_level)

  TIP=(Year Level Y) tiplabel=(Year='Academic Term' Y='Students Enrolled' Level ='Level') */;

  keylegend / position=right noborder;

run;

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

The Graph Template Language (GTL). The template for you graph would look something like the following definition. Just add your tip control to the BARCHART statement, and use the template with PROC SGRENDER.

proc template;

define statgraph barchart;

begingraph;

   layout datalattice columnvar=residency_desc / rowdatarange=unionall columndatarange=union;

      layout prototype;

         barchart x=FOUR_DIGIT_YEAR y=STUDENTS_ENROLLED / stat=sum group=degree_level name="bar";

      endlayout;

      sidebar / align=right spacefill=false;

         discretelegend "bar" / border=false;

      endsidebar;

   endlayout;

endgraph;

end;

run;

proc sgrender data=somedata template=barchart; run;

View solution in original post

6 REPLIES 6
DanH_sas
SAS Super FREQ

There is in SAS 9.4. Given the content of your SGPANEL request, you could write it in GTL and control the tip content there.

DavidPhillips2
Rhodochrosite | Level 12

What does “write it in GTL" mean? 

DanH_sas
SAS Super FREQ

The Graph Template Language (GTL). The template for you graph would look something like the following definition. Just add your tip control to the BARCHART statement, and use the template with PROC SGRENDER.

proc template;

define statgraph barchart;

begingraph;

   layout datalattice columnvar=residency_desc / rowdatarange=unionall columndatarange=union;

      layout prototype;

         barchart x=FOUR_DIGIT_YEAR y=STUDENTS_ENROLLED / stat=sum group=degree_level name="bar";

      endlayout;

      sidebar / align=right spacefill=false;

         discretelegend "bar" / border=false;

      endsidebar;

   endlayout;

endgraph;

end;

run;

proc sgrender data=somedata template=barchart; run;

DavidPhillips2
Rhodochrosite | Level 12

tooltip2.png

The tooltip code does not error out here but it seems like it is not enabled.

proc template;

define statgraph barchart;

begingraph;

   layout datalattice columnvar=residency_desc / rowdatarange=unionall columndatarange=union headerlabeldisplay=value;

      layout prototype;

         barchart x=FOUR_DIGIT_YEAR y=STUDENTS_ENROLLED / stat=sum group=degree_level name="bar" orient=horizontal  

  TIP=(x Y) tiplabel=(x='Academic Term' Y='Students Enrolled');

      endlayout;

      sidebar / align=right spacefill=false;

         discretelegend "bar" / border=false;

      endsidebar;

   endlayout;

endgraph;

end;

run;

proc sgrender data=enrollment template=barchart; run;

DanH_sas
SAS Super FREQ

On the ODS GRAPHICS statement, you have to have the IMAGEMAP option enabled:

ods graphics / imagemap;

DanH_sas
SAS Super FREQ

As an aside, you might want to put ACROSS=1 on the DISCRETELEGEND and REVERSE=TRUE on the ROWAXISOPTS to get back the original picture:

proc template;

define statgraph barchart;

begingraph;

   layout datalattice columnvar=residency_desc / rowdatarange=unionall columndatarange=union headerlabeldisplay=value

                                                                             rowaxisopts=(reverse=true);

      layout prototype;

         barchart x=FOUR_DIGIT_YEAR y=STUDENTS_ENROLLED / stat=sum group=degree_level name="bar" orient=horizontal 

  TIP=(x Y) tiplabel=(x='Academic Term' Y='Students Enrolled');

      endlayout;

      sidebar / align=right spacefill=false;

         discretelegend "bar" / border=false across=1;

      endsidebar;

   endlayout;

endgraph;

end;

run;

proc sgrender data=enrollment template=barchart; run;

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