Hi,
I have a code that generates circles (as pie charts) on a map depending on scores of various locations (in degrees) and the top "X" (defined in a macro variable) will be in a different color and have their respective rank in the middle of that circle:
Now, this is simply accomplished with an annotated dataset, but in the bottom I would like to add a small table with only the top "X" observations' rank, name and value.
I've tried various things like adding text with different HSYS values, but they get distorted after they're projected and I can't assign real world coordinates to that text (always has to be bottom left, regardless of selected country/region).
What I'd like to see is the following below. If it's combinable within the annotation dataset despite the projection to always have it in the bottom left, that would be great.
Thanks in advance.
I would really try not projecting the annotate set for your box and use percent of display for all of your XSYS, YSYS and HSYS (3) instead of mixing axis and area. You can have two annotate sets if needed, one on the proc statement and another in the choro options.
It would help to see the annotate code you've used.
It may be that you shouldn't project afterwards, I generally have the annotate data in System display coordinates if it isn't actually part of a map.
DATA anno;
SET &tablename.;
RETAIN XSYS YSYS '2' HSYS '3'
FLAG 1 WHEN 'a' OBS 0 maxpat;
LENGTH TEXT $50
COLOR FUNCTION POSITION $9
STYLE $25;
DROP maxpat;
obs=obs+1;
if obs=1 THEN DO;
size=&maxsize.;
maxpat=Aantal_Patienten;
END;
ELSE DO;
size=&maxsize.*Aantal_Patienten/maxpat;
END;
IF (obs <= &nr_labels.) THEN DO;
FUNCTION= 'pie';
POSITION= '5';
ROTATE= 360;
STYLE= 'psolid';
COLOR= 'aD03030aa';
OUTPUT;
FUNCTION= 'pie';
POSITION= '5';
STYLE= 'pempty';
COLOR= 'aA02020FF';
OUTPUT;
FUNCTION= 'label';
STYLE= 'Albany AMT';
POSITION= '5';
SIZE= 1.6;
COLOR= 'yellow';
TEXT= cat(' ',left(strip(obs)));
OUTPUT;
END;
ELSE DO;
FUNCTION= 'pie';
POSITION= '5';
ROTATE= 360;
STYLE= 'psolid';
COLOR= 'a1464F4aa';
OUTPUT;
FUNCTION= 'pie';
POSITION= '5';
STYLE= 'pempty';
COLOR= 'a000000FF';
OUTPUT;
END;
RUN;
DATA combo;
SET anno mapsgfk.&country.;
RUN;
PROC GPROJECT DATA=combo OUT=proj DUPOK DEGREES LATLON EASTLONG;
ID ID;
RUN;
DATA TX LABEL;
SET proj;
IF flag=1 THEN OUTPUT label;
ELSE OUTPUT TX;
RUN;
PROC GMAP DATA=tx MAP=tx ANNO=label;
WHERE id in (&Region.);
ID id;
CHORO id1 / COUTLINE=black nolegend;
RUN;
QUIT;
-------------------------------------------------
I had already deleted the wrong code for trying to get the box on there though. My plan there was to create/draw a table with its bottomleft corner at 10px from the bottomleft edge. If I added that into the anno code, it would either distort the map or be redefined new X/Y coordinates by the projection.
I would really try not projecting the annotate set for your box and use percent of display for all of your XSYS, YSYS and HSYS (3) instead of mixing axis and area. You can have two annotate sets if needed, one on the proc statement and another in the choro options.
Hi ballardw,
Thank you so much for your advice!
It worked like a charm by creating a seperate second annotation dataset with HSYS, which is done after the first annotation set containing the geographic data is projected together with the map.
WimB,
Mr ballardw's hints, tips, advice and suggestions have helped me greatly. Based on items I've learned from him, I created something similar (but different) by placing a proc report and a proc gmap on the same page. Using ODS TEXT, or Proc Print, or Proc Report, etc... statements, you could place your text in one column and your map in another column. I created a text file with the words I needed. Then I ran a proc report of the text file and proc gmap that placed both outputs in the same ODS file= ,
options nocenter orientation=landscape;
ods pdf BOOKMARKGEN=OFF columns=2 uniform startpage=yes;
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 the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.