%let name=towing_suv_search; filename odsout '.'; /* A little SAS/Graph example to help me search for a towing vehicle ... */ proc sql noprint; /* Find the largest city from each county */ create table cities as select unique statecode, county, city, pop, 1 as flag from maps.uscity group by statecode, county having pop=max(pop); /* now merge in the zip code(s) for each city */ create table cities as select unique cities.*, zipcode.zip from cities left join sashelp.zipcode on (cities.statecode=zipcode.statecode) and (cities.city=zipcode.city); quit; run; /* We really only need 1 zipcode for each city (otherwise we'll have multiple html href drilldowns stacked up on dots (cities) that have multiple zipcodes). Therefore just take the first one. */ proc sort data=cities out=cities; by statecode city; run; data cities; set cities; by statecode city; if first.city then output; run; /* Get the lat/long of each city */ proc geocode data=cities (where=(statecode not in ('AK' 'HI' 'PR'))) out=cities method=city addressstatevar=statecode; run; data my_map; set mapsgfk.us_states (where=(statecode not in ('AK' 'HI'))); run; data combined; set my_map cities; run; proc gproject data=combined out=combined latlong eastlong degrees dupok; id statecode; run; data my_map cities; set combined; if flag=1 then output cities; else output my_map; run; %macro do_map(make,model,title); /* Create annotated dot for each city */ data anno_cities; set cities; length function color $8 style $50 text $20 html $1000; xsys='2'; ysys='2'; hsys='3'; when='a'; color='blue'; function='pie'; style='pempty'; rotate=360; size=.35; html= 'title='|| quote( trim(left(city))||', '||trim(left(statecode)) )|| ' href='|| quote('http://www.autotrader.com/fyc/searchresults.jsp?'|| 'page_location=findacar%3A%3Aispsearchform&search_type=both'|| '&address='||trim(left(zip))|| '&maxMileage=150000'|| '&minPrice=2000'|| '&maxPrice=18000'|| '&distance='||trim(left(&radius))|| '&startYear=2000'|| '&endYear=2010'|| '&make='||trim(left("&make"))|| '&model='||trim(left("&model"))|| '&vehicleStyleCodes=AWD4WD'|| '&sortBy=derivedpriceASC' ); run; pattern1 v=s c=grayf5; goptions gunit=pct htitle=4.0 htext=5.0 ftitle="albany amt" ftext="albany amt/bold"; goptions ctext=gray33; title1 ls=1.5 "Click dots to see vehicles for sale within &radius miles of each city..."; proc gmap map=my_map data=my_map anno=anno_cities; note font="albany amt/bold" color=blue move=(5,6) box=1 bcolor=grayf5 "&title"; id statecode; choro segment / levels=1 nolegend coutline=gray55 des='' name="&name"; run; %mend; goptions device=png; goptions xpixels=900 ypixels=600; goptions border; ODS LISTING CLOSE; ODS HTML path=odsout body="&name..htm" (title="Towing SUV search") style=htmlblue; %let radius=50; %do_map(CHEV,TAHOE,Chevy Tahoe); %do_map(DODGE,DURANG,Dodge Durango); %do_map(TOYOTA,SEQUOIA,Toyota Sequoia); %do_map(NISSAN,PATHARMADA,Nissan Armada); %do_map(FORD,EXPEDI,Ford Expedition); %do_map(FORD,EXCURSION,Ford Excursion); %do_map(CHEV,ASTRO,Chevy Astro); %do_map(GMC,YUKON,GMC Yukon); /* */ quit; ODS HTML CLOSE; ODS LISTING;