Data visualization with SAS programming

Replacing state abbreviations on a map with tiny "sparklines" with time trends

Reply
Contributor
Posts: 47

Replacing state abbreviations on a map with tiny "sparklines" with time trends

Does anyone have any thoughts for generating tiny line plots to center on each state (in place of or along with a state abbreviation)?  If I generated each little plot with a tiny x and y pixel size separately it seems like I could create an annotate data base that could include these just as one includes the state abbreviations - something similar to the pre and post image commands in ODS.  Alternatively, has anyone had experience annotating unicode characters on a map - I could display a trend indicator using unicode characters if nothing else.  The output will be PDF.  Thanks in advance for any suggestions!

I will be trying to do a similar thing in PROC REPORT, annotating the little plots in one of the columns of the report.

Cheers, Louise

SAS Super FREQ
Posts: 8,645

Replacing state abbreviations on a map with tiny "sparklines" with time trends

Hi,

  You saw this paper?? http://www2.sas.com/proceedings/forum2008/262-2008.pdf

cynthia

SAS Employee
Posts: 963

Replacing state abbreviations on a map with tiny "sparklines" with time trends

I was hoping someone might have a slick/graceful/easy way to do this (maybe a macro or something)...

But since nobody has posted one up, I'll provide some info on how this could 'hypothetically' be done...

Similar to how you can annotate text on a GMap (using the annotate 'label' function), you can also annotate images on a GMap (using the 'image' function) ... in this case, the images would be very small GPlots that you have created ahead of time.  The 'trick' (ie, the difficult part) is that you cannot easily center the image over the map areas like you can the text (using position='5').

With an annotated image, you must specify the bottom/left corner, and the top/right corner.  Therefore the way to "center" an image on a certain location on a GMap is to first 'move' to the center (using xsys/ysys=2), and then change to the relative % coordinate system (xsys/ysys=9) and move a slight bit to the left & down for the bottom/left corner of the image, and then 2-times that offset amount for the top/right corner of the image.  Here's an example (it annotates hockey team images instead of sparkline graph images)...

data logo_anno; set logo_anno (keep = x y x_offset y_offset country province city Teamname logo);
  length function style $8 html $1000;
  hsys='3'; when='a';
  xsys='2'; ysys='2'; function='move'; output;
  xsys='9'; ysys='9';
  x=-2.0+x_offset; y=-2.5+y_offset; function='move'; output;
  html='alt="'||trim(left(Teamname))||'" href="http://www.google.com/search?&q='||trim(left(Teamname))||'"';

  x=2.0*2; y=2.5*2; function='image'; imgpath=logo; style='fit'; output;
run;

And the output it produces:

http://robslink.com/SAS/democd32/hockey.htm

http://robslink.com/SAS/democd32/hockey_info.htm

-----

An *alternative* which doesn't require annotate, and doesn't require coming up with coordinates for the bottom/left & top/right corner of each annotated image, might be to use javascript "popup" images for the graphs.  Here is an example:

http://robslink.com/SAS/democd51/census_2010.htm

http://robslink.com/SAS/democd51/census_2010_info.htm

Post a Question
Discussion Stats
  • 2 replies
  • 210 views
  • 0 likes
  • 3 in conversation