09-09-2022
aaaaaaaa21
Calcite | Level 5
Member since
02-13-2017
- 7 Posts
- 0 Likes Given
- 0 Solutions
- 0 Likes Received
-
Latest posts by aaaaaaaa21
Subject Views Posted 5964 03-14-2018 04:39 AM 5970 03-14-2018 03:53 AM 6020 03-14-2018 12:24 AM 2364 01-28-2018 05:13 PM 2457 01-28-2018 07:34 AM -
Activity Feed for aaaaaaaa21
- Posted Re: Proc gmap for longitude latitude data of a city on SAS Programming. 03-14-2018 04:39 AM
- Posted Re: Proc gmap for longitude latitude data of a city on SAS Programming. 03-14-2018 03:53 AM
- Posted Proc gmap for longitude latitude data of a city on SAS Programming. 03-14-2018 12:24 AM
- Posted Re: ERROR: Procedure SGMAP not found. on SAS Programming. 01-28-2018 05:13 PM
- Posted ERROR: Procedure SGMAP not found. on SAS Programming. 01-28-2018 07:34 AM
03-14-2018
04:39 AM
I did. I went through the third edition (the link you provided). I actually had already went through it a few days back too. I searched through the search box - I came across several examples that usese longitutde and latitude. But all of them either have Zipcode along with it or are used to trim a given map. In my case, I have the dataset related to San Fransisco, for each date (01/01/2018) and for those dates, I have crime types, where the crime happened (interms of longitude and latitude; x and y-coordinates). This data is in excel file. Now, I know how to draw a .shp file or use a zipcode for mapping. I know how to use SAS VA too. However, I did not find an example of how to create a map/graph based on those limited information. Any suggestions will be appreciated.
... View more
03-14-2018
03:53 AM
Thank you for the information. I have the SAS/Graph. But I am still not sure which statement to use to run my longitude and latitude (or my x and y-coordinates). If you do not mind, can you give me an example of a statement where I can use longitude and latitude (or my x and y-coordinates)?
... View more
03-14-2018
12:24 AM
Hello Community, I am using Base SAS to analyze a crime dataset related to one of the cities of US. I have a dataset that has x-coordinate, y-coordinate, longitude, and latitude data related to the city. Can I use Proc gmap or any other function to map these crime locations for this city? I am stuck and I could not proceed ahead with it. Again, I am aware of SAS visual analytics but that is not what I want to use. I want this to be done through Base SAS. Please provide some help. Thank you in advance.
... View more
01-28-2018
07:34 AM
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-SGMAP/ta-p/426743. 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: 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:
... View more