%let name=korean_labels_map; filename odsout '.'; /* This example is modeled after the following Tech Support example: http://support.sas.com/kb/56/546.html You must start your SAS session using the utf8 encoding, in order to run this example. I do it by running the following from the DOS command line: sas.exe -config "c:\program files\sashome\x86\sasfoundation\9.4\nls\u8\sasv9.cfg" Actually, I got tired of typing all that, so I set up a .bat file ... korean_labels_map.bat, which contains the following: u: cd u:\public_html\democd90\ sas.exe korean_labels_map.sas -config "c:\program files\sashome\x86\sasfoundation\9.4\nls\u8\sasv9.cfg" */ %annomac; /* First, create the map of South Korea, with borders by province */ data korea_map; set mapsgfk.south_korea (where=(density<=3) drop=resolution); run; proc gproject data=korea_map out=korea_map eastlong latlong degrees project=cylindri latmin=17; id id; run; proc gremove data=korea_map out=korea_map; id id1 id; by id1 notsorted; run; /* Calculate the x/y centroid for each area in the map */ %centroid(korea_map,korea_centers,id1,segonly=1); proc sql noprint; /* Get the province names */ create table province_names as select unique id1, id1name, id1nameu from mapsgfk.south_korea_attr; /* Merge the x/y centers with the text data */ create table province_names as select unique province_names.*, korea_centers.x, korea_centers.y from province_names left join korea_centers on province_names.id1=korea_centers.id1; quit; run; /* turn the names into annotate commands */ data province_names; set province_names; /* see defect S1320793 */ length text $200 color $8 my_html $300; my_html= 'title='||quote( trim(left(input(id1nameu,$uesc500.)))||'0d'x|| trim(left(id1name)))|| ' href='||quote('#'||trim(left(id1))); xsys='2'; ysys='2'; hsys='d'; when='a'; function='label'; /* this is the korean character version */ text=trim(left(input(id1nameu, $uesc500.))); position='b'; color='gray22'; size=11; output; /* this is the english version of the text (positioned below the Korean version) */ text=trim(left(id1name)); position='e'; color='gray88'; size=8; output; run; /* adjust label positions for a few of the labels */ data province_names; set province_names; if id1name='Seoul' then do; y=y+2; x=x+2; end; if id1name='Incheon' then do; y=y-3; x=x-7; end; if id1name='Gyeonggi-do' then do; x=x-5; y=y-12; end; if id1name='Gyeongsangnam-do' then do; y=y+3; end; if id1name='Busan' then do; y=y-2; end; if id1name='Chungcheongnam-do' then do; y=y+3; end; if id1name='Chungcheongbuk-do' then do; y=y+11; x=x+5; end; run; /* ------------------------------------------------------------ */ /* Get the map */ data provinces_map; set mapsgfk.south_korea (drop=resolution); original_id=_n_; run; /* Calculate the x/y centroid for each area in the map */ %centroid(provinces_map,centers,id,segonly=1); proc sql noprint; create table district_names as select unique id1, id1name, id1nameu, id, idname, idnameu from mapsgfk.south_korea_attr; /* Merge the x/y centers with the text data */ create table district_names as select unique district_names.*, centers.x, centers.y from district_names left join centers on district_names.id=centers.id; quit; run; /* turn the district_names into annotate commands */ data district_names; set district_names; length text $200 color $8 my_html $300; my_html= 'title='||quote( trim(left(input(idnameu,$uesc500.)))||'0d'x|| trim(left(idname)))|| ' href='||quote('#'||trim(left(id1))); xsys='2'; ysys='2'; hsys='d'; when='a'; function='label'; /* this is the Korean character version */ text=trim(left(input(idnameu, $uesc500.))); position='b'; color='gray22'; size=11; output; /* this is the english version of the text (positioned below the Korean version) */ text=trim(left(idname)); position='e'; color='gray88'; size=8; output; run; /* adjust label positions for labels, if necessary */ data district_names; set district_names; /* if idname='Sheng Zhixia Jihang Zheng Chan Wie' then y=y-.008; */ run; %macro do_map(prov); ods html anchor="&prov"; data temp_data; set district_names (where=(id1="&prov")); run; data temp_map; set provinces_map (where=(id1="&prov")); run; data anno_title; set temp_data (obs=1); length text $200; xsys='3'; ysys='3'; hsys='d'; when='a'; function='label'; position='6'; x=2; y=97; text=input(id1nameu, $uesc500.); color='gray22'; size=16; output; y=y-4.5; text=trim(id1name); color='gray88'; size=11; output; run; title h=5pct ' '; footnote; goptions xpixels=850 ypixels=700; proc gmap data=temp_data map=temp_map anno=anno_title; id id; choro id / nolegend coutline=cxDFAE74 anno=temp_data html=my_html des='' name="&name._&prov"; run; %mend; goptions device=png; goptions border; ODS LISTING CLOSE; ODS HTML path=odsout body="&name..htm" (title="Korean text labels on sas map") style=htmlblue; goptions gunit=pct htext=2.25 ftext='albany amt' ctext=gray44; data anno_title; length text $200; xsys='3'; ysys='3'; hsys='d'; when='a'; function='label'; style='albany amt/bold'; position='5'; color='gray24'; size=24; x=80; y=94; text="South Korea"; output; y=y-6; text="Provinces"; output; run; pattern1 v=s c=cxfdfbf2 repeat=1000; title; footnote; goptions xpixels=750 ypixels=800; proc gmap data=province_names map=korea_map anno=anno_title; id id1; choro id1 / nolegend coutline=cxDFAE74 anno=province_names html=my_html des='' name="&name"; run; proc sql noprint; create table loop as select unique id1 from district_names; quit; run; data _null_; set loop; call execute('%do_map('|| id1 ||');'); run; quit; ODS HTML CLOSE; ODS LISTING;