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

Hi 

 

I am currently working with North Korea Missile Data file. The code along with the data can be found here: https://communities.sas.com/t5/SAS-Communities-Library/Mapping-North-Korean-Missile-Tests-with-Proc-....

 

I followed the exact code and it still gives me ERROR: Procedure SGMAP not found. 

 

Then I worked on other similar project related to SGMAP with code posted here on blogs. For some reason, my SGMAP code gives error statement all the time. 

 

Please suggest. 

 

Thank you. 

 

 

 

 

First Cut

 

I believe that creating a great map is as much about art as science so I generally start out with a simple rendering of my data and build on that incrementally until I am happy with the result. I firstly imported the data using Proc Import.

 

 

proc import file="/folders/myshortcuts/Dropbox/north_korea_missile_test_database.xlsx"
            out=nktests
            dbms=xlsx replace;
  /*--- Use Excel column headings as SAS variable names. */ 
  getnames=yes;
  /*--- Specify Excel sheet name and data range to import. */
  range='Facilities$A2:G23';
run;

 

 

The latitude and longitude variables are in character format in the file so I needed to create numeric versions and discard one test where the location was “Unknown”.

 

 

/* Convert the latitude and longitude values to numeric */
data nktests;
	set nktests(where=(facility ne "Unknown"));
	lat_num  = input(latitude, best. );
	long_num = input(longitude, best. );
run;

 

Having done that, I’m now ready to try my first map. Here’s the code I used:

 

 

title 'North Korean Missile Tests';

proc sgmap plotdata=nktests;
  openstreetmap;
  bubble x=long_num y=lat_num 
    size=number_of_tests / 
    name='Facilities' datalabel=facility 
    datalabelattrs=(color=red) datalabelpos=right;
  keylegend 'Facilities';
run;
quit;

 

This is the result:

 

First Cut.png

So far so good - I have a map but there are some things I’m not 100% happy with:

 

  • Although SAS does its best not to overlap the labels on a bubble plot in this case the bubbles are too numerous and close together for it to be successful;
  • I’m not happy with my chosen color for the labels – it isn’t clear enough against the base map;
  • The title could be more descriptive i.e. what does the relative size of the bubbles mean;
  • You should always give an attribution for your data (it may even be a requirement for permission to use it);

 

Second Cut

 

In order to solve the problem of the overlapping labels I’m only going to show a label for the most used site and at the same time I’ll take the opportunity to make the label bigger, change the color and add some descriptive text. In order to discover which is the most used site I’ll use Proc Rank descending with ties=low. If, as in this case, there are one or more records for a rank the smallest of the ranks is assigned. In this case both the Kittaeryong Missile Base and the North Wonsan facility have held 20 tests therefore we’ll be showing a label for both of these facilities.

 

One useful feature of the way labels work in Proc SGMAP is that if there is no data for an observation in the label variable then SAS ignores that row when rendering the labels. I’m therefore going to create a label for each of the observations where the rank is equal to 1. I do this in a data step creating a new variable (called newlabel) which holds the facility name plus the number of tests carried out there. I’ll also take the opportunity to improve my header and add some footer information giving the source and an explanation of what the relative size of the bubbles means. Here is the code for the second cut of my map

 

 

/* Determine which facility is used the most */
proc sort data=nktests;
	by descending number_of_tests;
run;

proc rank data=nktests out=nktestrank descending ties=low;
	var number_of_tests;
	ranks numrank;
run;

/* Set a label for the most used facility/facilities */
data nktests2;
	set nktestrank;
	if numrank=1 then 
          newlabel=strip(facility)||" - Number of Tests="||put(number_of_tests,2.);
run;

title 'North Korean Missile Tests';
title2 'Location of Launch Facilities';
footnote j=l 'Data from The James Martin Center for Nonproliferation Studies'
 j=r 'Relative Number of Launches per Site';
proc sgmap plotdata=nktests2;
 openstreetmap;
 bubble x=long_num y=lat_num size=number_of_tests / 
   datalabel=newlabel datalabelattrs=(color=black size=10pt) 
   datalabelpos=right;
run;
quit;

 

This is the result:

 

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

What version of SAS are you running? PROC SGMAP was added to the recent SAS 9.4M5 release.

View solution in original post

3 REPLIES 3
Shmuel
Garnet | Level 18

To make your long story short i quote:  "I followed the exact code and it still gives me ERROR: Procedure SGMAP not found. "

 

Usually the message of procedure not found  is the result of missing some licence or module was not installed.

 

Is it the first time you use SGMAP procedure? Have you used it already successfuly on same installlation of sas?

Check you setinit log. Maybe your licence ended ?

 

PeterClemmensen
Tourmaline | Level 20

What version of SAS are you running? PROC SGMAP was added to the recent SAS 9.4M5 release.

aaaaaaaa21
Calcite | Level 5

Thank you. 

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!

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.

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
  • 3 replies
  • 1703 views
  • 0 likes
  • 3 in conversation