/*--Close each segment polygon by repeating the first vertex--*/ /*--Remove Alsaka, Hawaii & Puerto Rico--*/ data usa; set maps.states(where=(density<=1 and (state not in(2, 15, 72)))); length pid $8; retain x1 y1; keep state segment x y pid; by state segment; /*--Make unique Id for each state+segment combination--*/ pid=put(state, 3.0) || put(segment, 3.0); /*--Save the first vertex--*/ if first.segment=1 then do; x1=x; y1=y; output; end; else do; output; end; /*--Append first vertex again--*/ if last.segment=1 then do; x=x1; y=y1; output; end; run; /*proc print;run;*/ data usa_map_pop; set usa end=last; drop conv lat long; format pop 1.0; length city $12; conv=3.14159265 / 180; output; if last=1 then do; state=102; segment=1; density=0; pid=''; City='New York'; lat=40+47/60; long=73+58/60; x=long*conv; y=lat*conv; pop=8.1; output; state=103; segment=1; density=0; pid=''; City='Houston'; lat=29+45/60; long=95+31/60; x=long*conv; y=lat*conv; pop=2.1; output; state=104; segment=1; density=0; pid=''; City='Chicago'; lat=41+50/60; long=87+37/60; x=long*conv; y=lat*conv; pop=2.7; output; state=105; segment=1; density=0; pid=''; City='Los Angeles';lat=34+3/60; long=118+15/60; x=long*conv; y=lat*conv; pop=3.8; output; end; run; /*proc print;run;*/ /*--Project map + city data--*/ proc gproject data=usa_map_pop out=usap; id state; run; /*proc print;run;*/ /*--Separate pop data from Map--*/ data usa3; set usap; xo=.; yo=.; if city ne ' ' then do; xc=x; yc=y; x=.; y=.; segment=.; state=.; end; run; /*proc prin;run;*/ proc template; define statgraph PopulationMap; begingraph; entrytitle 'Population of Top Four US Cities in Millions'; entryfootnote halign=left 'Using Series and Bubble plots'; layout overlayequated / xaxisopts=(offsetmin=0 offsetmax=0.1 display=none) yaxisopts=(offsetmin=0 offsetmax=0 display=none); seriesplot x=x y=y / group=pid lineattrs=graphdatadefault(color=gray); bubbleplot x=xc y=yc size=pop / datatransparency=0.3 datalabel=city bubbleradiusmin=15 bubbleradiusmax=30 datalabelattrs=(size=9); scatterplot x=xc y=yc / markercharacter=pop markercharacterattrs=(size=14 weight=bold) ; endlayout; endgraph; end; run; ods listing; ods graphics / reset width=4in height=3in antialiasmax=4000 imagename='PopulationMap'; proc sgrender data=usa3 template=PopulationMap; run; ods graphics / reset width=4in height=3in antialiasmax=4000 imagename='PopulationBar'; title 'Population of Top Four US Cities in Millions'; proc sgplot data=usa3; vbar city / response=pop dataskin=pressed datalabel; yaxis grid display=(nolabel); run;