/*--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 usa2; set usa end=last; drop conv lat long; length city $12; conv=3.14159265 / 180; output; if last=1 then do; state=101; segment=1; density=0; pid=''; city='Raleigh'; lat=35+46/60; long=78+39/60; x=long*conv; y=lat*conv; output; state=102; segment=1; density=0; pid=''; City='New York'; lat=40+47/60; long=73+58/60; x=long*conv; y=lat*conv; output; state=103; segment=1; density=0; pid=''; City='Dallas'; lat=32+46/60; long=96+46/60; x=long*conv; y=lat*conv; output; state=104; segment=1; density=0; pid=''; City='Chicago'; lat=41+50/60; long=87+37/60; x=long*conv; y=lat*conv; 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; output; end; run; /*proc print;run;*/ /*--Project map + city data--*/ proc gproject data=usa2 out=usap; id state; run; /*proc print;run;*/ /*--Find coordinates for Raleigh--*/ data _null_; set usap; if city='Raleigh' then do; call symput ('xo', x); call symput ('yo', y); end; run; /*--Separate city data from Map and set vector origins to Raleigh--*/ data usa3; set usap; xo=.; yo=.; if city ne ' ' then do; xc=x; yc=y; x=.; y=.; segment=.; state=.; if city ne 'Raleigh' then do; xo=&xo; yo=&yo; end; end; run; /*proc print;run;*/ proc template; define statgraph AirlineRouteMap; begingraph; entrytitle 'Some Airline Routes from Raleigh'; entryfootnote halign=left 'Using Series, Scatter & Vector plots'; layout overlayequated / xaxisopts=(offsetmax=0.05 display=none) yaxisopts=(display=none); seriesplot x=x y=y / group=pid lineattrs=graphdatadefault(color=lightgray); vectorplot x=xc y=yc xorigin=xo yorigin=yo; scatterplot x=xc y=yc / group=city datalabel=city datalabelattrs=(size=10) markerattrs=graphdatadefault(symbol=circlefilled); endlayout; endgraph; end; run; ods listing; ods graphics / reset width=4in height=2.5in antialiasmax=4000 imagename='AirlineRouteMap'; proc sgrender data=usa3 template=AirlineRouteMap; run;