Data visualization with SAS programming

SGPanel, Hbar Tooltip Override Feature Similar to the Series Plot Tooltip

Accepted Solution Solved
Reply
Super Contributor
Posts: 465
Accepted Solution

SGPanel, Hbar Tooltip Override Feature Similar to the Series Plot Tooltip

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;


Accepted Solutions
Solution
‎01-15-2015 02:13 PM
SAS Super FREQ
Posts: 890

Re: SGPanel, Hbar Tooltip Override Feature Similar to the Series Plot Tooltip

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


All Replies
SAS Super FREQ
Posts: 890

Re: SGPanel, Hbar Tooltip Override Feature Similar to the Series Plot Tooltip

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.

Super Contributor
Posts: 465

Re: SGPanel, Hbar Tooltip Override Feature Similar to the Series Plot Tooltip

What does “write it in GTL" mean? 

Solution
‎01-15-2015 02:13 PM
SAS Super FREQ
Posts: 890

Re: SGPanel, Hbar Tooltip Override Feature Similar to the Series Plot Tooltip

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;

Super Contributor
Posts: 465

Re: SGPanel, Hbar Tooltip Override Feature Similar to the Series Plot Tooltip

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;

SAS Super FREQ
Posts: 890

Re: SGPanel, Hbar Tooltip Override Feature Similar to the Series Plot Tooltip

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

ods graphics / imagemap;

SAS Super FREQ
Posts: 890

Re: SGPanel, Hbar Tooltip Override Feature Similar to the Series Plot Tooltip

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;

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 529 views
  • 0 likes
  • 2 in conversation