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.
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.
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.
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!
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.