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

Dear all,

I have a simple subgrouped vbar chart with proc gchart. I's like to do a drill down when the user clicks on one value of the x axis (not a click an one bar). Is that possible?

I tried to change the values of the x axis by putting an html link around it like this:

data work.for_graph;

     set work.mydata;

     xaxis_value = cats("<a href='http://www.sas.de'>",myValue,"</a>");

run;

But SAS then prints the whole string from above as value under the x axis. A click has no effect.

Best regards

Eva

1 ACCEPTED SOLUTION

Accepted Solutions
GraphGuy
Meteorite | Level 14

There's no built-in feature in gchart to do this, but you can suppress the default bar midpoint text labels, and then annotate them, and have html drilldown for the annotated text.  Here's an example:

%let name=anno_xaxis;

filename odsout '.';

/*

Suppress the usual midpoint axis text values,

and then annotate your own with html drilldown.

*/

data mydata;

format population comma12.0;

input st $ 1-2 population;

year=2000;

datalines;

VA  7078515

NC  8049313

SC  4012012

GA  8186453

FL 15982378

;

run;

data myanno; set mydata;

length html $500 text $20;

xsys='2'; ysys='1';

function='label';

style='albany amt';

position='5';

midpoint=st;

y=-3;

when='a';

text=trim(left(st));

html='title='||quote(

'State: '|| trim(left(st)) ||'0D'x||

'Population: '|| trim(left(put(population,comma12.0)))

)||

' href="http://www.state.'||trim(left(lowcase(st)))||'.us"';

run;

GOPTIONS DEVICE=gif;

ODS LISTING CLOSE;

ODS HTML path=odsout body="&name..htm"

(title="GCHART w/ GIF ODS HTML Drilldown")

style=sasweb;

goptions noborder gunit=pct htitle=6 htext=3.5;

axis1 label=none value=(color=white);

axis2 label=none order=(0 to 20000000 by 5000000) minor=none offset=(0,0);

pattern v=solid color=cx43a2ca; 

title1 "Year 2000 U.S. Census Population";

title2 color=gray "GCHART w/ GIF ODS HTML Drilldown";

footnote color=gray "(text annotated as bar labels has drilldown)";

proc gchart data=mydata anno=myanno;

vbar st / discrete

type=sum sumvar=population

ascending

width=8

maxis=axis1

raxis=axis2

autoref cref=gray

clipref

coutline=black

des='' name="&name" ; 

run;

quit;

ODS HTML CLOSE;

ODS LISTING;

View solution in original post

4 REPLIES 4
GraphGuy
Meteorite | Level 14

There's no built-in feature in gchart to do this, but you can suppress the default bar midpoint text labels, and then annotate them, and have html drilldown for the annotated text.  Here's an example:

%let name=anno_xaxis;

filename odsout '.';

/*

Suppress the usual midpoint axis text values,

and then annotate your own with html drilldown.

*/

data mydata;

format population comma12.0;

input st $ 1-2 population;

year=2000;

datalines;

VA  7078515

NC  8049313

SC  4012012

GA  8186453

FL 15982378

;

run;

data myanno; set mydata;

length html $500 text $20;

xsys='2'; ysys='1';

function='label';

style='albany amt';

position='5';

midpoint=st;

y=-3;

when='a';

text=trim(left(st));

html='title='||quote(

'State: '|| trim(left(st)) ||'0D'x||

'Population: '|| trim(left(put(population,comma12.0)))

)||

' href="http://www.state.'||trim(left(lowcase(st)))||'.us"';

run;

GOPTIONS DEVICE=gif;

ODS LISTING CLOSE;

ODS HTML path=odsout body="&name..htm"

(title="GCHART w/ GIF ODS HTML Drilldown")

style=sasweb;

goptions noborder gunit=pct htitle=6 htext=3.5;

axis1 label=none value=(color=white);

axis2 label=none order=(0 to 20000000 by 5000000) minor=none offset=(0,0);

pattern v=solid color=cx43a2ca; 

title1 "Year 2000 U.S. Census Population";

title2 color=gray "GCHART w/ GIF ODS HTML Drilldown";

footnote color=gray "(text annotated as bar labels has drilldown)";

proc gchart data=mydata anno=myanno;

vbar st / discrete

type=sum sumvar=population

ascending

width=8

maxis=axis1

raxis=axis2

autoref cref=gray

clipref

coutline=black

des='' name="&name" ; 

run;

quit;

ODS HTML CLOSE;

ODS LISTING;

Eva
Quartz | Level 8 Eva
Quartz | Level 8

I don't know annotate yet. But it seems worth learning.What you gave me as an example is exactly what I need. I guess I can use the html= option as addition to the above example? Because my customer wants to be able to click on the bar and the xaxis value (and also in a subgrouped bar chart by the way where clicking on a subgroup versus clicking on the value of the x axis makes sense in that I give a different target site depending on whether the user clicks on the subgroup or the xaxis value).

GraphGuy
Meteorite | Level 14

Yep - exactly!  You can use both at the same time ... gchart's html= option to control the drilldown for the bar segments, and the html variable in the annotate data set to control the annotated bar midpoint labels (for your drilldown for the whole bar).

Eva
Quartz | Level 8 Eva
Quartz | Level 8

Great! Many thanx for your help.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

Discussion stats
  • 4 replies
  • 858 views
  • 3 likes
  • 2 in conversation