Using code based on Mike's paper, but slightly revised, you could get distance and time with:
* enter two zip codes;
%let z1=12203;
%let z2=20500;
* no changes required below this line;
filename x url "http://maps.google.com/maps?daddr=&z2.%nrstr(&saddr)=&z1";
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 want;
infile z recfm=f lrecl=&filesize. eof=done;
input @ "distance:'" @;
input text $50.;
distance = input(scan(text,1,"'"),$20.);
time = input(scan(text,3,"'"),$20.);
output;
stop;
done:
run;
filename x clear;
filename z clear;
Does Mike's sasCommunity.org page on the topic provide what you are looking for?:
http://www.sascommunity.org/wiki/Driving_Distances_and_Drive_Times_using_SAS_and_Google_Maps
Hi,
I have that paper. I want to know how to extract all goole maps web source information into one variable in a SAS dataset?
for example, in mike's code
* enter two zip codes;
%let z1=12203;
%let z2=27513;
* no changes required below this line;
filename x url "http://maps.google.com/maps?daddr=&z2.%nrstr(&saddr)=&z1";
data drive;
retain zip1 &z1 zip2 &z2;
infile x lrecl=32000 pad;
......
how to input all information from x into one variable in sas dataset?
Thanks
hi,
in Mike's code,
loc = find(_infile_,'dditd>');
but i can't find 'dditd>' in the source information.
I know Mike mentioned that string in his paper, but I don't think it is still used on the current Google Maps' page. You can search for such strings as:
distance:'
time:'
summary:'
the single quotes at the end of those strings are necessary to be part of the string and the fields appear to be separated by commas.
Hi,
My logic is
step 1. extract whole goole map web information into sigle variable in SAS dataset.
step 2. use find or substr function to search target string and then get the distance and time information.
Now, I dont know how to extract whole goole map web information into sigle variable in SAS dataset.
Are you able to show me some sample coding for that?
much appreciated.
Using code based on Mike's paper, but slightly revised, you could get distance and time with:
* enter two zip codes;
%let z1=12203;
%let z2=20500;
* no changes required below this line;
filename x url "http://maps.google.com/maps?daddr=&z2.%nrstr(&saddr)=&z1";
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 want;
infile z recfm=f lrecl=&filesize. eof=done;
input @ "distance:'" @;
input text $50.;
distance = input(scan(text,1,"'"),$20.);
time = input(scan(text,3,"'"),$20.);
output;
stop;
done:
run;
filename x clear;
filename z clear;
Hi,
Thank you so much.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.