BookmarkSubscribeRSS Feed
SQU
Calcite | Level 5 SQU
Calcite | Level 5

Hi,

I have a scatter plot of weight versus height, and mouse-over can show weight and height numbers for each observation, but I'd like to show more than just x and y; I want to see name and age as well.

The code is below. Any help will be greatly appreciated.

Thanks,

SQU

ods listing close;

ods html file="c:\temp\pie.html" (title="Weight-Height Scatter Plot")

nogtitle nogfootnote style=statdoc gpath="c:\temp\";

goptions reset=all

goptions device=Java;

symbol i=none value=plus r=100000;

data test;

infile datalines dlm=',';

input name $ Sex $ age height weight;

datalines;

Alfred,M,14,69.0,112.5

Alice,F,13,56.5,84.0

Barbara,F,13,65.3,98.0

Carol,F,14,62.8,102.5

Henry,M,14,63.5,102.5

James,M,12,57.3,83.0

;

run;

proc gplot data=test;

      plot height * weight;

run;

quit;

goptions reset=all;

ods html close;

ods listing;

5 REPLIES 5
GraphGuy
Meteorite | Level 14

I see you're using device=java ... in SAS/Graph, device=java (or activex) typically show the values being plotted, by default.  To have custom chart-tip hover-text, you can put your custom text in a variable in your data set (coded a special way as html title= or alt= tags), and then use the gplot "html=" option to point to that variable.

Also, I usually use device=png (or gif) for custom chart tips.  Device=java (or activex) might or might not support the custom text, depending on which version you are using (and possibly depending on exactly how you set up your variable).  Too many unknowns for me, so I use png.

Here is a simple example:

http://robslink.com/SAS/democd23/scat.htm

http://robslink.com/SAS/democd23/scat_info.htm

And here is the important bit of the code:

data mydata; set mydata;

length htmlvar $500;

htmlvar=

'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;

proc gplot data=mydata;

plot population*st=1 /

haxis=axis1 vaxis=axis2 vzero

html=htmlvar;

run;

Bill_in_Toronto
Obsidian | Level 7

Hi:

  Just wondering if you noticed the posting https://communities.sas.com/thread/38666. It shows how you can build on Robert's code in the reply above to include information other than a link in a mouse over.

Bill.

SQU
Calcite | Level 5 SQU
Calcite | Level 5

Thank you, Bill. That's helpful.

Informatician
Calcite | Level 5

Can the html statement be used with proc sgscatter? I keep trying to add it to my code and I throw an error no matter where I place it. Please advise.

 

data case_provider;
set centurion_physician;
length myhtml $ 250;
if nurse_traffic ~=. then provider_type="Nurse Practitioner";
if physician_traffic ~= . then provider_type= "Physician";

myhtml='title='||quote(
"Provider: "||strip(provider_type)||" "||trim(left(pcp_name))||'0D'X||
"Unique Cases: "||trim(left(unique_cases))||'0D'X||
"Unique Consults: "||trim(left(unique_consults))||'0D'X||
"Total Consults: "||strip(total_consults)||'0D'X||
"Cases Missing Site Detail: "||trim(left(missing_site_ct))
)
||' '|| 'href="'||"&hardcoded_drilldown"||'"';

run;

title "Utilization and Response Times by Provider Type";
proc sgscatter data=case_provider;
plot (unique_cases provider_type )*avg_response_hours / colorresponse=avg_response_hours

markerattrs=(symbol=CircleFilled size=14)

filledoutlinedmarkers
colormodel=(CX3288BD CX99D594 CXE6F598 CXFEE08B CXFC8D59 CXD53E4F);

label unique_cases ="Unique Cases" avg_response_hours= "Average Response Time in Hours"
;

run;
quit;

DanH_sas
SAS Super FREQ

For SGSCATTER, use the TIP option on the PLOT statement to list out the variables you want to see, and turn on the IMAGEMAP option on the ODS GRAPHICS statement.

 

Hope this helps!

Dan

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 3342 views
  • 0 likes
  • 5 in conversation