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/

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 1 reply
  • 1166 views
  • 0 likes
  • 2 in conversation