%let name=earth_at_night;
filename odsout '.';

/* get the city locations */
data dot_anno; set mapsgfk.world_cities;
anno_flag=1;
if idname in ('China' 'Taiwan' 'South Korea' 'Philippines') then do;
 if ranuni(123)<.03 then output;
 end;
else if idname in ('Germany' 'Netherlands' 'Belgium' 'United Kingdom') then do;
 if ranuni(123)<.40 then output;
 end;
else output;
run;

/* get the world map */
data mymap; 
 set mapsgfk.world (where=( (density<=2) and (cont ^= 97) ) drop = x y);
run;

/* project the map and the dots */
data combined; set mymap dot_anno; run;
proc gproject data=combined out=combined dupok project=gall latlong eastlong degrees;
  id id;
run;
data mymap dot_anno; set combined;
  if anno_flag=1 then output dot_anno;
  else output mymap;
run;

data dot_anno; set dot_anno;
xsys='2'; ysys='2'; when='a';
function='point'; color='white'; 
run;

/* put the name of each country in html hover-text */
data hover_data; set mapsgfk.world_attr;
length my_html $100;
my_html='title='||quote(trim(left(idname)));
colorvar=1;
run;


goptions device=png;
goptions xpixels=1450 ypixels=800;
goptions cback=gray55;

ODS LISTING CLOSE;
ODS HTML path=odsout body="&name..htm"
 (title="SAS night sky simulation")
 nogtitle style=htmlblue;

title1 f="albany amt/bold" h=14pt "Simulation of Earth's Lights at Night";

pattern1 v=msolid c=black;

proc gmap map=mymap data=hover_data anno=dot_anno;
id id; 
choro colorvar / levels=1 nolegend coutline=gray22  
 html=my_html
 des='' name="&name";
run;

quit;
ODS HTML CLOSE;
ODS LISTING;
