I'm trying to find the distance between 3,600 pairs of zipcodes, patient and their provider. I attached 50 pairs in a CSV file. Patient zipcode is patz, and provider zipcode is provz. I run SAS 9.4 on Windows 10 in a VM using Parallels, so I'm used to things taking a little bit longer than they would when I run it on a Windows computer. Except I left it to run overnight last night, and it wasn't done seven hours later. Is there a problem with my code? libname ob "\\Mac\Home\Desktop\SAS";
proc import file="\\Mac\Home\Desktop\zip.csv"
dbms=csv
out=zip
replace;
run;
data _null_;
call symputx('nzips',obs);
stop;
set zip nobs=obs;
run;
%macro distance_time (ds=, z1=, z2=, out=);
%do j=1 %to &nzips;
DATA _null_;
nrec = &j;
set zip point=nrec;
call symputx('patz',&z1);
call symputx('provz',&z2);
RUN;
filename x url "https://www.google.com/maps/dir/&z1/&z2/?force=lite";
filename z temp;
data _null_;
infile x recfm=f lrecl=1 end=eof;
file z recfm=f lrecl=1;
input @1 x $char1.;
put @1 x $char1.;
if eof;
call symputx('filesize',_n_);
run;
data temp;
keep z1 z2 distance units time;
z1="&z1";
z2="&z2";
infile z recfm=f lrecl=&filesize. eof=done;
input @ 'miles' +(-15) @ '"' distance :comma12. text $30.;
units = scan(text,1,'"');
text = scan(text,3,'"');
select;
when (find(text,'d') ne 0) time = sum(86400*input(scan(text,1,' '),best.),
3600*input(scan(text,3,' '),best.));
when (find(text,'h') ne 0) time = sum(3600*input(scan(text,1,' '),best.),
60*input(scan(text,3,' '),best.));
otherwise time = 60*input(scan(text,1,' '),best.);
end;
output;
keep z1 z2 distance units time;
done:
output;
run;
filename x clear;
filename z clear;
proc append base=distance_time data=temp force;
run;
%end;
%mend;
%distance_time (ds=zip, z1=patz, z2=provz, out=dist_time);
data ob.distance_time;
set dist_time;
run;
proc export data=ob.distance_time
dbms=xlsx
outfile="\\Mac\Home\Desktop\distance.xlsx"
replace;
run; Thanks!!!
... View more