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)
);
/*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;
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;
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.
What does “write it in GTL" mean?
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;
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;
On the ODS GRAPHICS statement, you have to have the IMAGEMAP option enabled:
ods graphics / imagemap;
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 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.