BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
veronicasalmaso
Obsidian | Level 7

Hello! I'm fairly new in SAS, so I'm still learning the basics.
I have a question regarding "proc sgmap". I have two different dataset I'd like to put on the same map. 

This is the code for the first map 

proc sgmap plotdata = abc; 
Title H=2 "abc";
openstreetmap;
scatter x =  lon y = lat / legendlabel = "abc" markerattrs=(color=black size=3 symbol=circlefilled); 
run; 

And this is the code for the second map

proc sgmap plotdata = xyz;
Title H=2 "Punti xyz";
openstreetmap;
scatter x =  longi y = lati / legendlabel = "xyz" markerattrs=(color=Red size=7 symbol=diamondfilled); 
run; 

 

 

How can I combine the two maps? 


My idea was to join the two datasets and do something like this:

proc sgmap plotdata = combined;
Title H=2 "Combined";
openstreetmap;
scatter x =  lon y = lat / legendlabel = "abc" markerattrs=(color=black size=3 symbol=circlefilled); 
scatter x =  longi y = lati / legendlabel = "xyz" markerattrs=(color=Red size=7 symbol=diamondfilled); 
run; 

Is it possible to do it like this? I'm not sure how to merge the datasets though.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Maps tend to use one set of coordinate variables.

Since you have two different variables for coordinate pairs first would be get one set of coordinate variables.

 

data toplot;
   set abc
       xyz (rename=(longi=lon lati=lat))
       indsname=dsn;
   ;
   source= scan(dsn,2);
run;

proc sgmap data=toplot;
  scatter x=lon y=lat/ group=source;
run;

Use DATTRMAP and associate with the procedure and group values with the ATTRID option on the Scatter statement, or STYLEATTRS to set the sequence of colors, marker types and size for the values of the group variable overriding the defaults of the current style..

 

If you  have not seen it the INDSNAME option on a set statement creates an automatic variable with the libname.datasetname contributing the current observation to the data set. Abve that is DSN for the varible name. The scan function gets the second part, just the data set ABC or XYZ removing the library name.

View solution in original post

2 REPLIES 2
ballardw
Super User

Maps tend to use one set of coordinate variables.

Since you have two different variables for coordinate pairs first would be get one set of coordinate variables.

 

data toplot;
   set abc
       xyz (rename=(longi=lon lati=lat))
       indsname=dsn;
   ;
   source= scan(dsn,2);
run;

proc sgmap data=toplot;
  scatter x=lon y=lat/ group=source;
run;

Use DATTRMAP and associate with the procedure and group values with the ATTRID option on the Scatter statement, or STYLEATTRS to set the sequence of colors, marker types and size for the values of the group variable overriding the defaults of the current style..

 

If you  have not seen it the INDSNAME option on a set statement creates an automatic variable with the libname.datasetname contributing the current observation to the data set. Abve that is DSN for the varible name. The scan function gets the second part, just the data set ABC or XYZ removing the library name.

veronicasalmaso
Obsidian | Level 7
Thank you so much! I assume dan is a typo for dsn. It works perfectly.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 2 replies
  • 449 views
  • 2 likes
  • 2 in conversation