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

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:

Locations.png

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.

Locations_2.png

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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.

View solution in original post

5 REPLIES 5
ballardw
Super User

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.

WimB
Fluorite | Level 6

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.

ballardw
Super User

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.

WimB
Fluorite | Level 6

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.

jwillis
Quartz | Level 8

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-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!

What is Bayesian Analysis?

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.

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
  • 5 replies
  • 1274 views
  • 3 likes
  • 3 in conversation