/*2.运行下面代码*/
%macro sas_getMap;
data _null_;
length url $ 2048;
url = catt(
'http://maps.googleapis.com/maps/api/staticmap?markers=', urlencode(&address),
'&zoom=15',
'&size=', &height, 'x', &width,
'&sensor=false');
url = transtrn(trim(url), ' ', '%20');
call symputx('REQUEST_URL', url);
run;
filename img_fref &img_filename;
filename hdr_out "c:\temp\header.txt";
proc http
out = img_fref
url = "%superq(REQUEST_URL)"
headerout = hdr_out
method = "GET"
ct="application/x-www-form-urlencoded"
;
run;
data _null_;
infile hdr_out;
input;
if prxmatch('/^HTTP\/\S+\s+\d+/', _infile_);
status = scan(_infile_, 2, ' ');
if status = '200' then
call symputx('STATUS', 0);
else
call symputx('STATUS', status);
stop;
run;
%mend;
proc fcmp outlib=sasuser.funcs.web;
function sas_getMap(address $, height, width, img_filename $);
length status 8;
rc = run_macro('sas_getMap', address, height, width, img_filename, status);
return (status);
endsub;
quit;
data addresses;
length name $ 32 address $ 50;
infile datalines truncover;
input name address $128.;
datalines;
SCUT south china university of technology
;
run;
options cmplib=sasuser.funcs;
data _null_;
set addresses;
/* <Imagine report generation code here> */
rc = sas_getMap(address, 800, 600, catt('c:\temp\', name, '.png'));
if rc then
putlog 'ERROR: Could not get map for ' name;
run;



雷达卡




京公网安备 11010802022788号







