BookmarkSubscribeRSS Feed
tc
Lapis Lazuli | Level 10 tc
Lapis Lazuli | Level 10

MWSUG Conference LocationsMWSUG Conference Locations

Used SAS/GRAPH in 2011 to knock out an image for a Zazzle t-shirt (production run of 1!) commemorating the 36th anniversary of SAS Global Forum.

 

So, with MWSUG 2019 kicking off next Sunday in Chicago, here's a quick SAS ODS Graphics take on a chart to mark that conference's 30th anniversary.

 

Probably could've used the newer SGMAP procedure, but after seeing tips in write-ups by Sanjay Matange, Rick Wicklin, Robert Allison, and Louise Hadden, decided to opt for PROC SGPLOT and polygon/scatter plots!

 

Zazzle T-Shirt MockupZazzle T-Shirt Mockup

SGPANEL DetailSGPANEL Detail

SAS CODE

* Fun with SAS ODS Grapics: Maps of MWSUG Conference Locations (1990-2019);

data mwsugCities(keep=year city st);          * Get locations of past conferences from MWSUG website;
filename mwsug url "http://mwsug.org/pastconf.html"; * Web page with data on past conferences;
infile mwsug truncover;
input @"<tr><td colspan=2><b>" year 4. +3 cityst $char255.; * Scrape year, city, state;
if year^=.;
city=tranwrd(scan(cityst,1,","),"St. Louis","Saint Louis"); * Get city, recode St. Louis;
st=scan(scan(cityst,1,'<'),-1,",< ");         * Get state codes or names;
do s=1 to 56;                                 * Translate state names into codes;
  if st=fipnamel(s) then st=fipstate(s);      
end;  
 
proc sql;                                     * Add conference location for 2019;
insert into mwsugCities values(2019,"Chicago","IL");

                               * Map cities to colors (Tableau 10 Light RGB codes from gist.github.com/chebee7i/4041f848ee2710d500e6);
create table Hosted as select city, count(*) as hosted from mwsugCities group by 1 order by 2 desc, 1;

create table CityAttrMap as                   /* Create ODS Graphics attribute map of cities to colors for charts */
select "city" as id, city as value,           /* 13 colors for 13 unique cities */
       scan("CXAEC7E8 CXFFBB78 CX98DF8A CXFF9896 CXC5B0D5 CXC49C94 CXF7B6D2 CXC7C7C7 CXDBDB8D 
             CX9EDAE5 TAN GOLD TURQUOISE",monotonic()," ") as fillcolor
from hosted;
                                              * Add lat/long to conference locations;
create table mwsugCitiesGeo(rename=(x=xC y=yC)) as 
select m.year, u.* from mwsugCities m, sasfiles.uscity u
where m.city=u.city and m.st=u.statecode order by m.year;
  
libname mymaps '/folders/myfolders/mymaps/'; * Get outlines of MWSUG states from SAS US map;
data mwsugStates;
set mymaps.us(where=(statecode in ('IL' 'IN' 'IA' 'KS' 'MI' 'MN' 'MO' 'NE' 'ND' 'OH' 'SD' 'WI'))); 
seq=_n_+1;                                    * Maintain original order;
length pid $8;
keep state segment x y pid seq;
pid=put(state, 3.0)||put(segment, 3.0);       * Make unique polygon ID for each state+segment combo;

proc sql;                                     * Duplicate state outline data for each year and add year/city;
create table mwsugStates2 as select * from mwsugStates, mwsugCitiesGeo(keep=year City) order by seq;

data mwsug;                                   * Merge state outlines and city points together;
set mwsugStates2 mwsugCitiesGeo;

proc sql noprint;                             * Calc aspect ratio of points in map;
select (max(y)-min(y))/(max(x)-min(x)) into :aspect from mwsug; * Calc from: blogs.sas.com/content/sastraining/2017/03/21/create-pretty-map-proc-sgplot/;
 
ods listing image_dpi=250 gpath='/folders/myfolders/MWSUG2019/images'; * Image setup parameters;                                   
ods graphics on / reset antialias width=14in height=17in imagename="MWSUG" noborder ANTIALIASMAX=8400 LABELMAX=8400;
     
proc sgpanel data=mwsug aspect=&aspect subpixel noautolegend dattrmap=CityAttrMap; * Draw panel of maps!;
title height=54pt "MWSUG@30"; * 30 years of MWSUG conferences!;
panelby year / rows=6 columns=5 onepanel uniscale=all noheaderborder headerbackcolor=white novarname headerattrs=(weight=bold size=20pt color=black) noborder spacing=5;
rowaxis display=none offsetmin=.0 offsetmax=.0; colaxis display=none offsetmin=.0 offsetmax=.0;
polygon x=x y=y id=pid / fill outline group=city attrid=city lineattrs=(color=white); * Ploygon plot for maps, scatter plot for city points/labels;
scatter x=xc y=yc / markerattrs=(symbol=circlefilled color=black size=14pt) datalabel=city datalabelattrs=(weight=bold size=16pt color=black);
2 REPLIES 2
MichelleHomes
Meteorite | Level 14

What a fun way to celebrate the 30th anniversary of MWSUG. Interesting to also see the most visited city is Chicago too!

//Contact me to learn how Metacoda software can help keep your SAS platform secure - https://www.metacoda.com
Ksharp
Super User

That is very cool. I like idea of PROC SGPANEL .

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1220 views
  • 7 likes
  • 3 in conversation