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

Hi....I would like to annotate the names of a country and population size from a list so that the only the names on the country along with their population size appears on the world map. I have found a lot of information that annotates cities but I can't find much on countries. Thanks.

 

 

proc sgmap mapdata=maps.world maprespdata=sashelp.demographics; 
choromap id / mapid=id id=id; 
run;
1 ACCEPTED SOLUTION

Accepted Solutions
pink_poodle
Barite | Level 11

You would need to provide an appropriately subsetted dataset to the PLOTDATA = option of the PROC SGMAP statement. PLOTDATA supplies the TEXT statement of SGMAP procedure, that determines what is written on the map.

For example, this code would display country names from the variable idname:

 

PROC SQL;
   CREATE TABLE countrynames AS
	SELECT id AS id, mean(x) AS xc, mean(y) AS yc, min(idname) AS idname
	FROM maps.world
     /* You can also choose specific countries, e.g. WHERE idname IN ('Russia','Poland','Ukraine') */
	GROUP BY id;
QUIT;

PROC SGMAP MAPDATA = maps.world	        /* Map boundaries */
	   MAPRESTDATA = countrynames 	/* For colours */
	   PLOTDATA = countrynames 	/* For names */
;
    CHOROMAP idname / MAPID= id ID= id;
    TEXT X= xc Y= yc TEXT= idname / TEXTATTRS= (SIZE= 3pt COLOR= steel);
RUN;

Reference:  https://amadeus.co.uk/sas-tips/maps-in-ods-graphics-proc-sgmap/

View solution in original post

1 REPLY 1
pink_poodle
Barite | Level 11

You would need to provide an appropriately subsetted dataset to the PLOTDATA = option of the PROC SGMAP statement. PLOTDATA supplies the TEXT statement of SGMAP procedure, that determines what is written on the map.

For example, this code would display country names from the variable idname:

 

PROC SQL;
   CREATE TABLE countrynames AS
	SELECT id AS id, mean(x) AS xc, mean(y) AS yc, min(idname) AS idname
	FROM maps.world
     /* You can also choose specific countries, e.g. WHERE idname IN ('Russia','Poland','Ukraine') */
	GROUP BY id;
QUIT;

PROC SGMAP MAPDATA = maps.world	        /* Map boundaries */
	   MAPRESTDATA = countrynames 	/* For colours */
	   PLOTDATA = countrynames 	/* For names */
;
    CHOROMAP idname / MAPID= id ID= id;
    TEXT X= xc Y= yc TEXT= idname / TEXTATTRS= (SIZE= 3pt COLOR= steel);
RUN;

Reference:  https://amadeus.co.uk/sas-tips/maps-in-ods-graphics-proc-sgmap/

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 1 reply
  • 751 views
  • 0 likes
  • 2 in conversation