Dear,
I would like to plot a world map with proc gmap but the UK is missing on the map although it is in the data set.
I started from the data set maps.world and I put the full name of the country into 'longname'.
In my second data set, I have a variable that is 1 for UK and 0 for all other countries.
If I make a map with all countries, United Kingdom is missing on the map.
If I make a map with only United Kingdom, United Kingdom is drawn in the map. (But there is a strange line in the map)
If I select United Kingdom and some other countries, United Kingdom is still in the map.
But as soon as I add for example Ireland or Iceland, United Kingdom is missing in the map.
Does somebody knows how to fix this?
Many thanks!
Sara
My code:
options fmtsearch=(sashelp.mapfmts);
data wereldkaart;
set maps.world;
longname=put(id,glcnlu.);
run;
data uk;
format longname $20. uk;
longname="ICELAND"; UK=0; output;longname="ALBANIA"; UK=0; output;longname="ITALY"; UK=0; output;longname="LATVIA"; UK=0; output;
longname="ROMANIA"; UK=0; output;longname="AUSTRIA"; UK=0; output;longname="CYPRUS"; UK=0; output;longname="CROATIA"; UK=0; output;
longname="ISRAEL"; UK=0; output;longname="TURKEY"; UK=0; output;longname="LITHUANIA"; UK=0; output;longname="GREECE"; UK=0; output;
longname="BULGARIA"; UK=0; output;longname="SWEDEN"; UK=0; output;longname="FRANCE"; UK=0; output;longname="ESTONIA"; UK=0; output;
longname="SLOVAKIA"; UK=0; output;longname="UKRAINE"; UK=0; output;longname="FINLAND"; UK=0; output;longname="NORWAY"; UK=0; output;
longname="NETHERLANDS"; UK=0; output;longname="DENMARK"; UK=0; output;longname="BELGIUM"; UK=0; output;longname="UNITED KINGDOM"; UK=1; output;
longname="SWITZERLAND"; UK=0; output;longname="SLOVENIA"; UK=0; output;longname="GERMANY"; UK=0; output;longname="POLAND"; UK=0; output;
longname="SPAIN"; UK=0; output;longname="IRELAND"; UK=0; output;longname="HUNGARY"; UK=0; output;longname="PORTUGAL"; UK=0; output;
run;
goptions reset=all ;
options dev=actximg printerpath=png nodate nonumber;
ods printer file="I:\ALL.png" dpi=500;
proc gmap map=wereldkaart data=uk all;
id longname;
choro UK / cdefault=white;
run;
quit;
ods printer close;
goptions reset=all ;
options dev=actximg printerpath=png nodate nonumber;
ods printer file="I:\UK.png" dpi=500;
proc gmap map=wereldkaart (where=(longname = "UNITED KINGDOM")) data=uk all;
id longname;
choro UK / cdefault=white;
run;
quit;
ods printer close;
goptions reset=all ;
options dev=actximg printerpath=png nodate nonumber;
ods printer file="I:\UK_others.png" dpi=500;
proc gmap map=wereldkaart (where=(longname in ("BELGIUM","FRANCE","UNITED KINGDOM"))) data=uk all;
id longname;
choro UK / cdefault=white;
run;
quit;
ods printer close;
goptions reset=all ;
options dev=actximg printerpath=png nodate nonumber;
ods printer file="I:\UK_others_ICELAND.png" dpi=500;
proc gmap map=wereldkaart (where=(longname in ("BELGIUM","FRANCE","UNITED KINGDOM","ICELAND"))) data=uk all;
id longname;
choro UK / cdefault=white;
run;
quit;
ods printer close;
The stray line on the UK map is an indication of something wrong. The GLC code shows one LONGNAME for multiple IDs. So, United Kingdom is 416, 588 and 925. The UK has multiple GLC values in the country and you tried to treat them as one set of Polygons... thus it got confused when drawing them. It will work if you use "ID ID;" in Proc GMAP, but you will need to add ID to the data set UK.
It would be better to use the NEWER maps in the library MAPSGFK.
There is much more information in the data set and a *_attr data set that contains even more information.
data map; set mapsgfk.WORLD; if (ID="GB") then output; run;
proc gmap data=map map=map resolution=10; id id; choro id; run; quit;
or use the MAPSGFK.EUROPE data set:
data map; set mapsgfk.EUROPE; if (ID="GB") then output; run;
proc gmap data=map map=map resolution=10; id id; choro id; run; quit;
The stray line on the UK map is an indication of something wrong. The GLC code shows one LONGNAME for multiple IDs. So, United Kingdom is 416, 588 and 925. The UK has multiple GLC values in the country and you tried to treat them as one set of Polygons... thus it got confused when drawing them. It will work if you use "ID ID;" in Proc GMAP, but you will need to add ID to the data set UK.
It would be better to use the NEWER maps in the library MAPSGFK.
There is much more information in the data set and a *_attr data set that contains even more information.
data map; set mapsgfk.WORLD; if (ID="GB") then output; run;
proc gmap data=map map=map resolution=10; id id; choro id; run; quit;
or use the MAPSGFK.EUROPE data set:
data map; set mapsgfk.EUROPE; if (ID="GB") then output; run;
proc gmap data=map map=map resolution=10; id id; choro id; run; quit;
Many thanks! I could create the map I wanted 🙂
Sara
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.