DATA Step, Macro, Functions and more

Connection to url via filename failed: ERROR: Host name www.google.com not found.

Reply
Contributor
Posts: 22

Connection to url via filename failed: ERROR: Host name www.google.com not found.

Hi at all guys

 

I get the following errors running the code below which is posted here http://www.sascommunity.org/wiki/Driving_Distances_and_Drive_Times_using_SAS_and_Google_Maps

 

 

ERROR: Host name www.google.com not found.

ERROR 24-2: Invalid value for the LRECL option.

 

The cod eis below. It seems that I get problem in connecting to Google. Any idea about how to fix it? Bests

 

 data set with IDs and ADDRESSES;
data addresses;
length addr1 addr2 $50;
input 
@01 id     $5.
@10 addr1  $30.
@40 addr2  $30.
;
zip = input(scan(addr1,-1),5.);
set sashelp.zipcode (keep=zip poname statecode) key=zip / unique;
addr1 = catx(' ',catx(',+',scan(addr1,1,','),poname,statecode),zip);
zip = input(scan(addr2,-1),5.);
set sashelp.zipcode (keep=zip poname statecode) key=zip / unique;
addr2 = catx(' ',catx(',+',scan(addr2,1,','),poname,statecode),zip);
keep id addr: ;
datalines;
12345    59 LENOX AVE, 12203            1 UNIVERSITY PL, 12144
98989    616 COSBY ROAD, 13502          59 LENOX AVE, 12203
99999    59 Lenox Ave, 12203            SAS Campus Drive, 27513
87878    370 Frederick St, 94117        2129 N St NW, 20037
;
 
* place number of addresses in a macro variable;
data _null_;
call symputx('naddr',obs);
stop;
set addresses nobs=obs;
run;
 
* delete any data set named DISTANCE_TIME that might exist in the WORK library;
proc datasets lib=work nolist;
delete distance_time;
quit;
 
* use a loop within a macro to access Google Maps multiple time;
%macro distance_time;
%do j=1 %to &naddr;
data _null_;
nrec = &j;
set addresses point=nrec;
call symputx('id',id);
call symputx('a1',translate(trim(addr1),'+',' '));
call symputx('a2',translate(trim(addr2),'+',' '));
stop;
stop;
run;
 
filename x url "https://www.google.com/maps/dir/&a1/&a2/?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;
length addr1 addr2 $50;
id = "&id";
addr1 = upcase(translate("&a1",' ','+'));
addr2 = upcase(translate("&a2",' ','+'));
 
infile z recfm=f lrecl=&filesize. eof=done;
input @ 'miles' +(-15) @ '"' distance :comma12. text $30.;
units    = scan(text,1,'"');
text     = scan(text,3,'"');
 
* convert times to seconds;
  select;
* combine days and hours;
   when (find(text,'d') ne 0) time = sum(86400*input(scan(text,1,' '),best.), 
                                        3600*input(scan(text,3,' '),best.));
* combine hours and minutes;
   when (find(text,'h') ne 0) time = sum(3600*input(scan(text,1,' '),best.), 
                                        60*input(scan(text,3,' '),best.));
* just minutes;
   otherwise                  time = 60*input(scan(text,1,' '),best.);
  end;
output;
keep id addr1 addr2 distance units time;
label
addr1 = 'ADDRESS #1'
addr2 = 'ADDRESS #2'
id    = 'ID #'
distance = 'DISTANCE (MILES)'
time     = 'TIME (HR:MIN)'
;
stop;
done:
output;
run;
 
filename x clear;
filename z clear;
 
proc append base=distance_time data=temp;
run;
%end;
%mend;
 
* use the macro;
%distance_time;
 
* 
add the distance between ZIP centroids 
(should be "in same ballpark" as driving distance)
;
data distance_time;
set distance_time;
* ZIP should be LAST entry in the addresses;
zip_city = zipcitydistance(scan(addr1,-1),scan(addr2,-1));
label zip_city = 'ZIPCITYDISTANCE FUNCTION';
run;
 
title "DRIVING DISTANCE AND TIMES";
proc print data=distance_time label noobs;
var id addr1 addr2 distance time zip_city;
format time time6.;
run;

 

Super User
Posts: 11,343

Re: Connection to url via filename failed: ERROR: Host name www.google.com not found.

Run your code with OPTIONS MPRINT ;

 

The error messages will then appear near the code causing them. At the end of a macro with loops it is very hard to tell when the error occurs.

 

 

Contributor
Posts: 22

Re: Connection to url via filename failed: ERROR: Host name www.google.com not found.

 

Just done, it seems there is not more in terms of error explanation

 

 

1 The SAS System 03:29 Thursday, February 4, 2016

1 ;*';*";*/;quit;run;
2 OPTIONS PAGENO=MIN;
3 %LET _CLIENTTASKLABEL='Program';
4 %LET _CLIENTPROJECTPATH='';
5 %LET _CLIENTPROJECTNAME='';
6 %LET _SASPROGRAMFILE=;
7
8 ODS _ALL_ CLOSE;
9 OPTIONS DEV=ACTIVEX;
10 GOPTIONS XPIXELS=0 YPIXELS=0;
11 FILENAME EGSR TEMP;
12 ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR
13 STYLE=HtmlBlue
14 STYLESHEET=(URL="file:///C:/Program%20Files/SASHome2/SASEnterpriseGuide/6.1/Styles/HtmlBlue.css")
15 NOGTITLE
16 NOGFOOTNOTE
17 GPATH=&sasworklocation
18 ENCODING=UTF8
19 options(rolap="on")
20 ;
NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR
21
22 GOPTIONS ACCESSIBLE;
23 * data set with IDs and ADDRESSES;
24 data addresses;
25 length addr1 addr2 $50;
26 input
27 @01 id $5.
28 @10 addr1 $30.
29 @40 addr2 $30.
30 ;
31 zip = input(scan(addr1,-1),5.);
32 set sashelp.zipcode (keep=zip poname statecode) key=zip / unique;
33 addr1 = catx(' ',catx(',+',scan(addr1,1,','),poname,statecode),zip);
34 zip = input(scan(addr2,-1),5.);
35 set sashelp.zipcode (keep=zip poname statecode) key=zip / unique;
36 addr2 = catx(' ',catx(',+',scan(addr2,1,','),poname,statecode),zip);
37 keep id addr: ;
38 datalines;

NOTE: The data set WORK.ADDRESSES has 4 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

43 ;

44
45 * place number of addresses in a macro variable;
46 data _null_;
47 call symputx('naddr',obs);
48 stop;
49 set addresses nobs=obs;
50 run;

NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
2 The SAS System 03:29 Thursday, February 4, 2016

 

51
52 * delete any data set named DISTANCE_TIME that might exist in the WORK library;
53 proc datasets lib=work nolist;
54 delete distance_time;
55 quit;

NOTE: Deleting WORK.DISTANCE_TIME (memtype=DATA).
NOTE: PROCEDURE DATASETS used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds

56
57 * use a loop within a macro to access Google Maps multiple time*^;
58 %macro distance_time;
59 %do j=1 %to &naddr;
60 data _null_;
61 nrec = &j;
62 set addresses point=nrec;
63 call symputx('id',id);
64 call symputx('a1',translate(trim(addr1),'+',' '));
65 call symputx('a2',translate(trim(addr2),'+',' '));
66 stop;
67 stop;
68 run;
69
70 filename x url 'https://www.google.com/maps/dir/&a1/&a2/?force=lite'
71 debug
72 prompt debug;
73 filename z temp;
74
75 data _null_;
76 infile x recfm=f lrecl=1 end=eof;
77 file z recfm=f lrecl=1;
78 input @1 x $char1.;
79 put @1 x $char1.;
80 if eof;
81 call symputx('filesize',_n_);
82 run;
83
84 data temp;
85 length addr1 addr2 $50;
86 id = "&id";
87 addr1 = upcase(translate("&a1",' ','+'));
88 addr2 = upcase(translate("&a2",' ','+'));
89
90 infile z recfm=f lrecl=&filesize. eof=done;
91 input @ 'miles' +(-15) @ '"' distance :comma12. text $30.;
92 units = scan(text,1,'"');
93 text = scan(text,3,'"');
94
95 * convert times to seconds;
96 select;
97 * combine days and hours;
98 when (find(text,'d') ne 0) time = sum(86400*input(scan(text,1,' '),best.),
99 3600*input(scan(text,3,' '),best.));
3 The SAS System 03:29 Thursday, February 4, 2016

100 * combine hours and minutes;
101 when (find(text,'h') ne 0) time = sum(3600*input(scan(text,1,' '),best.),
102 60*input(scan(text,3,' '),best.));
103 * just minutes;
104 otherwise time = 60*input(scan(text,1,' '),best.);
105 end;
106 output;
107 keep id addr1 addr2 distance units time;
108 label
109 addr1 = 'ADDRESS #1'
110 addr2 = 'ADDRESS #2'
111 id = 'ID #'
112 distance = 'DISTANCE (MILES)'
113 time = 'TIME (HR:MIN)'
114 ;
115 stop;
116 done:
117 output;
118 run;
119
120 filename x clear;
121 filename z clear;
122
123 proc append base=distance_time data=temp;
124 run;
125 %end;
126 %mend;
127 options mprint;
128 * use the macro;
129 %distance_time;
MPRINT(DISTANCE_TIME): data _null_;
MPRINT(DISTANCE_TIME): nrec = 1;
MPRINT(DISTANCE_TIME): set addresses point=nrec;
MPRINT(DISTANCE_TIME): call symputx('id',id);
MPRINT(DISTANCE_TIME): call symputx('a1',translate(trim(addr1),'+',' '));
MPRINT(DISTANCE_TIME): call symputx('a2',translate(trim(addr2),'+',' '));
MPRINT(DISTANCE_TIME): stop;
MPRINT(DISTANCE_TIME): stop;
MPRINT(DISTANCE_TIME): run;

NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds

MPRINT(DISTANCE_TIME): filename x url 'https://www.google.com/maps/dir/&a1/&a2/?force=lite' debug prompt debug;
MPRINT(DISTANCE_TIME): filename z temp;
MPRINT(DISTANCE_TIME): data _null_;
MPRINT(DISTANCE_TIME): infile x recfm=f lrecl=1 end=eof;
MPRINT(DISTANCE_TIME): file z recfm=f lrecl=1;
MPRINT(DISTANCE_TIME): input @1 x $char1.;
MPRINT(DISTANCE_TIME): put @1 x $char1.;
MPRINT(DISTANCE_TIME): if eof;
MPRINT(DISTANCE_TIME): call symputx('filesize',_n_);
MPRINT(DISTANCE_TIME): run;

NOTE: Unable to connect to host www.google.com. Check validity of host name.
ERROR: Host name www.google.com not found.
4 The SAS System 03:29 Thursday, February 4, 2016

NOTE: The file Z is:
Filename=/saswork/SAS_work41D5000062F8_lppma874.phx.aexp.com/#LN00099,
Owner Name=dcortell,Group Name=bis,
Access Permission=-rw-r--r--,
Last Modified=04Feb2016:09:03:06

NOTE: 0 records were written to the file Z.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds

MPRINT(DISTANCE_TIME): data temp;
MPRINT(DISTANCE_TIME): length addr1 addr2 $50;
MPRINT(DISTANCE_TIME): id = "12345";
MPRINT(DISTANCE_TIME): addr1 = upcase(translate("59+LENOX+AVE,+Albany,+NY+12203",' ','+'));
MPRINT(DISTANCE_TIME): addr2 = upcase(translate("1+UNIVERSITY+PL,+Rensselaer,+NY+12144",' ','+'));
NOTE 137-205: Line generated by the invoked macro "DISTANCE_TIME".
129 data temp; length addr1 addr2 $50; id = "&id"; addr1 = upcase(translate("&a1",' ','+')); addr2 =
129 ! upcase(translate("&a2",' ','+')); infile z recfm=f lrecl=&filesize. eof=done; input @ 'miles' +(-15) @ '"' distance
_
24
129 ! :comma12. text $30.; units = scan
ERROR 24-2: Invalid value for the LRECL option.

WARNING: Apparent symbolic reference FILESIZE not resolved.
MPRINT(DISTANCE_TIME): infile z recfm=f lrecl=&filesize. eof=done;
MPRINT(DISTANCE_TIME): input @ 'miles' +(-15) @ '"' distance :comma12. text $30.;
MPRINT(DISTANCE_TIME): units = scan(text,1,'"');
MPRINT(DISTANCE_TIME): text = scan(text,3,'"');
MPRINT(DISTANCE_TIME): * convert times to seconds;
MPRINT(DISTANCE_TIME): select;
MPRINT(DISTANCE_TIME): * combine days and hours;
MPRINT(DISTANCE_TIME): when (find(text,'d') ne 0) time = sum(86400*input(scan(text,1,' '),best.), 3600*input(scan(text,3,'
'),best.));
MPRINT(DISTANCE_TIME): * combine hours and minutes;
MPRINT(DISTANCE_TIME): when (find(text,'h') ne 0) time = sum(3600*input(scan(text,1,' '),best.), 60*input(scan(text,3,'
'),best.));
MPRINT(DISTANCE_TIME): * just minutes;
MPRINT(DISTANCE_TIME): otherwise time = 60*input(scan(text,1,' '),best.);
MPRINT(DISTANCE_TIME): end;
MPRINT(DISTANCE_TIME): output;
MPRINT(DISTANCE_TIME): keep id addr1 addr2 distance units time;
MPRINT(DISTANCE_TIME): label addr1 = 'ADDRESS #1' addr2 = 'ADDRESS #2' id = 'ID #' distance = 'DISTANCE (MILES)' time = 'TIME
(HR:MIN)' ;
MPRINT(DISTANCE_TIME): stop;
MPRINT(DISTANCE_TIME): done: output;
MPRINT(DISTANCE_TIME): run;

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.TEMP may be incomplete. When this step was stopped there were 0 observations and 6 variables.
WARNING: Data set WORK.TEMP was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
cpu time 0.01 seconds

5 The SAS System 03:29 Thursday, February 4, 2016

MPRINT(DISTANCE_TIME): filename x clear;
NOTE: Fileref X has been deassigned.
MPRINT(DISTANCE_TIME): filename z clear;
NOTE: Fileref Z has been deassigned.
MPRINT(DISTANCE_TIME): proc append base=distance_time data=temp;
MPRINT(DISTANCE_TIME): run;

NOTE: Appending WORK.TEMP to WORK.DISTANCE_TIME.
NOTE: BASE data set does not exist. DATA file is being copied to BASE file.
NOTE: There were 0 observations read from the data set WORK.TEMP.
NOTE: The data set WORK.DISTANCE_TIME has 0 observations and 6 variables.
NOTE: PROCEDURE APPEND used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds

MPRINT(DISTANCE_TIME): data _null_;
MPRINT(DISTANCE_TIME): nrec = 2;
MPRINT(DISTANCE_TIME): set addresses point=nrec;
MPRINT(DISTANCE_TIME): call symputx('id',id);
MPRINT(DISTANCE_TIME): call symputx('a1',translate(trim(addr1),'+',' '));
MPRINT(DISTANCE_TIME): call symputx('a2',translate(trim(addr2),'+',' '));
MPRINT(DISTANCE_TIME): stop;
MPRINT(DISTANCE_TIME): stop;
MPRINT(DISTANCE_TIME): run;

NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds

MPRINT(DISTANCE_TIME): filename x url 'https://www.google.com/maps/dir/&a1/&a2/?force=lite' debug prompt debug;
MPRINT(DISTANCE_TIME): filename z temp;
MPRINT(DISTANCE_TIME): data _null_;
MPRINT(DISTANCE_TIME): infile x recfm=f lrecl=1 end=eof;
MPRINT(DISTANCE_TIME): file z recfm=f lrecl=1;
MPRINT(DISTANCE_TIME): input @1 x $char1.;
MPRINT(DISTANCE_TIME): put @1 x $char1.;
MPRINT(DISTANCE_TIME): if eof;
MPRINT(DISTANCE_TIME): call symputx('filesize',_n_);
MPRINT(DISTANCE_TIME): run;

NOTE: Unable to connect to host www.google.com. Check validity of host name.
ERROR: Host name www.google.com not found.
NOTE: The file Z is:
Filename=/saswork/SAS_work41D5000062F8_lppma874.phx.aexp.com/#LN00100,
Owner Name=dcortell,Group Name=bis,
Access Permission=-rw-r--r--,
Last Modified=04Feb2016:09:03:07

NOTE: 0 records were written to the file Z.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

MPRINT(DISTANCE_TIME): data temp;
6 The SAS System 03:29 Thursday, February 4, 2016

MPRINT(DISTANCE_TIME): length addr1 addr2 $50;
MPRINT(DISTANCE_TIME): id = "98989";
MPRINT(DISTANCE_TIME): addr1 = upcase(translate("616+COSBY+ROAD,+Utica,+NY+13502",' ','+'));
MPRINT(DISTANCE_TIME): addr2 = upcase(translate("59+LENOX+AVE,+Albany,+NY+12203",' ','+'));
NOTE 137-205: Line generated by the invoked macro "DISTANCE_TIME".
129 data temp; length addr1 addr2 $50; id = "&id"; addr1 = upcase(translate("&a1",' ','+')); addr2 =
129 ! upcase(translate("&a2",' ','+')); infile z recfm=f lrecl=&filesize. eof=done; input @ 'miles' +(-15) @ '"' distance
_
24
129 ! :comma12. text $30.; units = scan
ERROR 24-2: Invalid value for the LRECL option.

WARNING: Apparent symbolic reference FILESIZE not resolved.
MPRINT(DISTANCE_TIME): infile z recfm=f lrecl=&filesize. eof=done;
MPRINT(DISTANCE_TIME): input @ 'miles' +(-15) @ '"' distance :comma12. text $30.;
MPRINT(DISTANCE_TIME): units = scan(text,1,'"');
MPRINT(DISTANCE_TIME): text = scan(text,3,'"');
MPRINT(DISTANCE_TIME): * convert times to seconds;
MPRINT(DISTANCE_TIME): select;
MPRINT(DISTANCE_TIME): * combine days and hours;
MPRINT(DISTANCE_TIME): when (find(text,'d') ne 0) time = sum(86400*input(scan(text,1,' '),best.), 3600*input(scan(text,3,'
'),best.));
MPRINT(DISTANCE_TIME): * combine hours and minutes;
MPRINT(DISTANCE_TIME): when (find(text,'h') ne 0) time = sum(3600*input(scan(text,1,' '),best.), 60*input(scan(text,3,'
'),best.));
MPRINT(DISTANCE_TIME): * just minutes;
MPRINT(DISTANCE_TIME): otherwise time = 60*input(scan(text,1,' '),best.);
MPRINT(DISTANCE_TIME): end;
MPRINT(DISTANCE_TIME): output;
MPRINT(DISTANCE_TIME): keep id addr1 addr2 distance units time;
MPRINT(DISTANCE_TIME): label addr1 = 'ADDRESS #1' addr2 = 'ADDRESS #2' id = 'ID #' distance = 'DISTANCE (MILES)' time = 'TIME
(HR:MIN)' ;
MPRINT(DISTANCE_TIME): stop;
MPRINT(DISTANCE_TIME): done: output;
MPRINT(DISTANCE_TIME): run;

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.TEMP may be incomplete. When this step was stopped there were 0 observations and 6 variables.
WARNING: Data set WORK.TEMP was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
cpu time 0.01 seconds

MPRINT(DISTANCE_TIME): filename x clear;
NOTE: Fileref X has been deassigned.
MPRINT(DISTANCE_TIME): filename z clear;
NOTE: Fileref Z has been deassigned.
MPRINT(DISTANCE_TIME): proc append base=distance_time data=temp;
MPRINT(DISTANCE_TIME): run;

NOTE: Appending WORK.TEMP to WORK.DISTANCE_TIME.
NOTE: There were 0 observations read from the data set WORK.TEMP.
NOTE: 0 observations added.
NOTE: The data set WORK.DISTANCE_TIME has 0 observations and 6 variables.
NOTE: PROCEDURE APPEND used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
7 The SAS System 03:29 Thursday, February 4, 2016

 

MPRINT(DISTANCE_TIME): data _null_;
MPRINT(DISTANCE_TIME): nrec = 3;
MPRINT(DISTANCE_TIME): set addresses point=nrec;
MPRINT(DISTANCE_TIME): call symputx('id',id);
MPRINT(DISTANCE_TIME): call symputx('a1',translate(trim(addr1),'+',' '));
MPRINT(DISTANCE_TIME): call symputx('a2',translate(trim(addr2),'+',' '));
MPRINT(DISTANCE_TIME): stop;
MPRINT(DISTANCE_TIME): stop;
MPRINT(DISTANCE_TIME): run;

NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds

MPRINT(DISTANCE_TIME): filename x url 'https://www.google.com/maps/dir/&a1/&a2/?force=lite' debug prompt debug;
MPRINT(DISTANCE_TIME): filename z temp;
MPRINT(DISTANCE_TIME): data _null_;
MPRINT(DISTANCE_TIME): infile x recfm=f lrecl=1 end=eof;
MPRINT(DISTANCE_TIME): file z recfm=f lrecl=1;
MPRINT(DISTANCE_TIME): input @1 x $char1.;
MPRINT(DISTANCE_TIME): put @1 x $char1.;
MPRINT(DISTANCE_TIME): if eof;
MPRINT(DISTANCE_TIME): call symputx('filesize',_n_);
MPRINT(DISTANCE_TIME): run;

NOTE: Unable to connect to host www.google.com. Check validity of host name.
ERROR: Host name www.google.com not found.
NOTE: The file Z is:
Filename=/saswork/SAS_work41D5000062F8_lppma874.phx.aexp.com/#LN00101,
Owner Name=dcortell,Group Name=bis,
Access Permission=-rw-r--r--,
Last Modified=04Feb2016:09:03:07

NOTE: 0 records were written to the file Z.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

MPRINT(DISTANCE_TIME): data temp;
MPRINT(DISTANCE_TIME): length addr1 addr2 $50;
MPRINT(DISTANCE_TIME): id = "99999";
MPRINT(DISTANCE_TIME): addr1 = upcase(translate("59+Lenox+Ave,+Albany,+NY+12203",' ','+'));
MPRINT(DISTANCE_TIME): addr2 = upcase(translate("SAS+Campus+Drive,+Cary,+NC+27513",' ','+'));
NOTE 137-205: Line generated by the invoked macro "DISTANCE_TIME".
129 data temp; length addr1 addr2 $50; id = "&id"; addr1 = upcase(translate("&a1",' ','+')); addr2 =
129 ! upcase(translate("&a2",' ','+')); infile z recfm=f lrecl=&filesize. eof=done; input @ 'miles' +(-15) @ '"' distance
_
24
129 ! :comma12. text $30.; units = scan
ERROR 24-2: Invalid value for the LRECL option.

WARNING: Apparent symbolic reference FILESIZE not resolved.
MPRINT(DISTANCE_TIME): infile z recfm=f lrecl=&filesize. eof=done;
8 The SAS System 03:29 Thursday, February 4, 2016

MPRINT(DISTANCE_TIME): input @ 'miles' +(-15) @ '"' distance :comma12. text $30.;
MPRINT(DISTANCE_TIME): units = scan(text,1,'"');
MPRINT(DISTANCE_TIME): text = scan(text,3,'"');
MPRINT(DISTANCE_TIME): * convert times to seconds;
MPRINT(DISTANCE_TIME): select;
MPRINT(DISTANCE_TIME): * combine days and hours;
MPRINT(DISTANCE_TIME): when (find(text,'d') ne 0) time = sum(86400*input(scan(text,1,' '),best.), 3600*input(scan(text,3,'
'),best.));
MPRINT(DISTANCE_TIME): * combine hours and minutes;
MPRINT(DISTANCE_TIME): when (find(text,'h') ne 0) time = sum(3600*input(scan(text,1,' '),best.), 60*input(scan(text,3,'
'),best.));
MPRINT(DISTANCE_TIME): * just minutes;
MPRINT(DISTANCE_TIME): otherwise time = 60*input(scan(text,1,' '),best.);
MPRINT(DISTANCE_TIME): end;
MPRINT(DISTANCE_TIME): output;
MPRINT(DISTANCE_TIME): keep id addr1 addr2 distance units time;
MPRINT(DISTANCE_TIME): label addr1 = 'ADDRESS #1' addr2 = 'ADDRESS #2' id = 'ID #' distance = 'DISTANCE (MILES)' time = 'TIME
(HR:MIN)' ;
MPRINT(DISTANCE_TIME): stop;
MPRINT(DISTANCE_TIME): done: output;
MPRINT(DISTANCE_TIME): run;

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.TEMP may be incomplete. When this step was stopped there were 0 observations and 6 variables.
WARNING: Data set WORK.TEMP was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
cpu time 0.01 seconds

MPRINT(DISTANCE_TIME): filename x clear;
NOTE: Fileref X has been deassigned.
MPRINT(DISTANCE_TIME): filename z clear;
NOTE: Fileref Z has been deassigned.
MPRINT(DISTANCE_TIME): proc append base=distance_time data=temp;
MPRINT(DISTANCE_TIME): run;

NOTE: Appending WORK.TEMP to WORK.DISTANCE_TIME.
NOTE: There were 0 observations read from the data set WORK.TEMP.
NOTE: 0 observations added.
NOTE: The data set WORK.DISTANCE_TIME has 0 observations and 6 variables.
NOTE: PROCEDURE APPEND used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds

MPRINT(DISTANCE_TIME): data _null_;
MPRINT(DISTANCE_TIME): nrec = 4;
MPRINT(DISTANCE_TIME): set addresses point=nrec;
MPRINT(DISTANCE_TIME): call symputx('id',id);
MPRINT(DISTANCE_TIME): call symputx('a1',translate(trim(addr1),'+',' '));
MPRINT(DISTANCE_TIME): call symputx('a2',translate(trim(addr2),'+',' '));
MPRINT(DISTANCE_TIME): stop;
MPRINT(DISTANCE_TIME): stop;
MPRINT(DISTANCE_TIME): run;

NOTE: DATA statement used (Total process time):
real time 0.00 seconds
9 The SAS System 03:29 Thursday, February 4, 2016

cpu time 0.00 seconds

MPRINT(DISTANCE_TIME): filename x url 'https://www.google.com/maps/dir/&a1/&a2/?force=lite' debug prompt debug;
MPRINT(DISTANCE_TIME): filename z temp;
MPRINT(DISTANCE_TIME): data _null_;
MPRINT(DISTANCE_TIME): infile x recfm=f lrecl=1 end=eof;
MPRINT(DISTANCE_TIME): file z recfm=f lrecl=1;
MPRINT(DISTANCE_TIME): input @1 x $char1.;
MPRINT(DISTANCE_TIME): put @1 x $char1.;
MPRINT(DISTANCE_TIME): if eof;
MPRINT(DISTANCE_TIME): call symputx('filesize',_n_);
MPRINT(DISTANCE_TIME): run;

NOTE: Unable to connect to host www.google.com. Check validity of host name.
ERROR: Host name www.google.com not found.
NOTE: The file Z is:
Filename=/saswork/SAS_work41D5000062F8_lppma874.phx.aexp.com/#LN00102,
Owner Name=dcortell,Group Name=bis,
Access Permission=-rw-r--r--,
Last Modified=04Feb2016:09:03:07

NOTE: 0 records were written to the file Z.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.00 seconds

MPRINT(DISTANCE_TIME): data temp;
MPRINT(DISTANCE_TIME): length addr1 addr2 $50;
MPRINT(DISTANCE_TIME): id = "87878";
MPRINT(DISTANCE_TIME): addr1 = upcase(translate("370+Frederick+St,+San+Francisco,+CA+94117",' ','+'));
MPRINT(DISTANCE_TIME): addr2 = upcase(translate("2129+N+St+NW,+Washington,+DC+20037",' ','+'));
NOTE 137-205: Line generated by the invoked macro "DISTANCE_TIME".
129 data temp; length addr1 addr2 $50; id = "&id"; addr1 = upcase(translate("&a1",' ','+')); addr2 =
129 ! upcase(translate("&a2",' ','+')); infile z recfm=f lrecl=&filesize. eof=done; input @ 'miles' +(-15) @ '"' distance
_
24
129 ! :comma12. text $30.; units = scan
ERROR 24-2: Invalid value for the LRECL option.

WARNING: Apparent symbolic reference FILESIZE not resolved.
MPRINT(DISTANCE_TIME): infile z recfm=f lrecl=&filesize. eof=done;
MPRINT(DISTANCE_TIME): input @ 'miles' +(-15) @ '"' distance :comma12. text $30.;
MPRINT(DISTANCE_TIME): units = scan(text,1,'"');
MPRINT(DISTANCE_TIME): text = scan(text,3,'"');
MPRINT(DISTANCE_TIME): * convert times to seconds;
MPRINT(DISTANCE_TIME): select;
MPRINT(DISTANCE_TIME): * combine days and hours;
MPRINT(DISTANCE_TIME): when (find(text,'d') ne 0) time = sum(86400*input(scan(text,1,' '),best.), 3600*input(scan(text,3,'
'),best.));
MPRINT(DISTANCE_TIME): * combine hours and minutes;
MPRINT(DISTANCE_TIME): when (find(text,'h') ne 0) time = sum(3600*input(scan(text,1,' '),best.), 60*input(scan(text,3,'
'),best.));
MPRINT(DISTANCE_TIME): * just minutes;
MPRINT(DISTANCE_TIME): otherwise time = 60*input(scan(text,1,' '),best.);
MPRINT(DISTANCE_TIME): end;
10 The SAS System 03:29 Thursday, February 4, 2016

MPRINT(DISTANCE_TIME): output;
MPRINT(DISTANCE_TIME): keep id addr1 addr2 distance units time;
MPRINT(DISTANCE_TIME): label addr1 = 'ADDRESS #1' addr2 = 'ADDRESS #2' id = 'ID #' distance = 'DISTANCE (MILES)' time = 'TIME
(HR:MIN)' ;
MPRINT(DISTANCE_TIME): stop;
MPRINT(DISTANCE_TIME): done: output;
MPRINT(DISTANCE_TIME): run;

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.TEMP may be incomplete. When this step was stopped there were 0 observations and 6 variables.
WARNING: Data set WORK.TEMP was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
cpu time 0.01 seconds

MPRINT(DISTANCE_TIME): filename x clear;
NOTE: Fileref X has been deassigned.
MPRINT(DISTANCE_TIME): filename z clear;
NOTE: Fileref Z has been deassigned.
MPRINT(DISTANCE_TIME): proc append base=distance_time data=temp;
MPRINT(DISTANCE_TIME): run;

NOTE: Appending WORK.TEMP to WORK.DISTANCE_TIME.
NOTE: There were 0 observations read from the data set WORK.TEMP.
NOTE: 0 observations added.
NOTE: The data set WORK.DISTANCE_TIME has 0 observations and 6 variables.
NOTE: PROCEDURE APPEND used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds

130
131 *
132 add the distance between ZIP centroids
133 (should be "in same ballpark" as driving distance)
134 ;
135 data distance_time;
136 set distance_time;
137 * ZIP should be LAST entry in the addresses;
138 zip_city = zipcitydistance(scan(addr1,-1),scan(addr2,-1));
139 label zip_city = 'ZIPCITYDISTANCE FUNCTION';
140 run;

NOTE: There were 0 observations read from the data set WORK.DISTANCE_TIME.
NOTE: The data set WORK.DISTANCE_TIME has 0 observations and 7 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

141
142 title "DRIVING DISTANCE AND TIMES";
143 proc print data=distance_time label noobs;
144 var id addr1 addr2 distance time zip_city;
145 format time time6.;
146 run;

11 The SAS System 03:29 Thursday, February 4, 2016

NOTE: No observations in data set WORK.DISTANCE_TIME.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds

147
148 GOPTIONS NOACCESSIBLE;
149 %LET _CLIENTTASKLABEL=;
150 %LET _CLIENTPROJECTPATH=;
151 %LET _CLIENTPROJECTNAME=;
152 %LET _SASPROGRAMFILE=;
153
154 ;*';*";*/;quit;run;
155 ODS _ALL_ CLOSE;
156
157
158 QUIT; RUN;
159

Super User
Posts: 11,343

Re: Connection to url via filename failed: ERROR: Host name www.google.com not found.

[ Edited ]

Actually it does, confirming mine and possibly your suspicion:

IN

NOTE: 0 records were written to the file Z.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds

MPRINT(DISTANCE_TIME): data temp;
MPRINT(DISTANCE_TIME): length addr1 addr2 $50;
MPRINT(DISTANCE_TIME): id = "12345";
MPRINT(DISTANCE_TIME): addr1 = upcase(translate("59+LENOX+AVE,+Albany,+NY+12203",​' ','+'));
MPRINT(DISTANCE_TIME): addr2 = upcase(translate("1+UNIVERSITY+PL,+Rensselaer,+NY+​12144",' ','+'));
NOTE 137-205: Line generated by the invoked macro "DISTANCE_TIME".
129 data temp; length addr1 addr2 $50; id = "&id"; addr1 = upcase(translate("&a1",' ','+')); addr2 =
129 ! upcase(translate("&a2",' ','+')); infile z recfm=f lrecl=&filesize. eof=done; input @ 'miles' +(-15) @ '"' distance
_
24
129 ! :comma12. text $30.; units = scan
ERROR 24-2: Invalid value for the LRECL option.

WARNING: Apparent symbolic reference FILESIZE not resolved.

The last line gives the proximate cause of the error: Filesize not resolved i.e. blank. So Lrecl= eof=done (since the macro variable is blank) reads EOF as the value for Lrecl.

 

 

And since your line:

filename x url 'https://www.google.com/maps/dir/&a1/&a2/?force=lit​e'

has the macro variables within single quotes they do not resolve.

Try

filename x url "https://www.google.com/maps/dir/&a1./&a2./?force=lit​e"

Also note the added periods to concatenate the resolved macro variables. Otherwise /&a1/&a2 would look for a Macro variable named &a1/  and give a different error message. 

But depending on how &a1 and &a2 resolve you may have other issues.

Contributor
Posts: 22

Re: Connection to url via filename failed: ERROR: Host name www.google.com not found.

Mmmm I think it is not the main error here the Filezie one. I mean, looking at the part of the code where the two errors display (after having done the changes you suggested) I get the following log below

 

 

 

 

MPRINT(DISTANCE_TIME): filename x url 
"https://www.google.com/maps/dir/370+Frederick+St,+San+Francisco,+CA+94117/2129+N+St+NW,+Washington,+DC+20037/?force=lite" debug 
prompt debug;
MPRINT(DISTANCE_TIME): filename z temp;
MPRINT(DISTANCE_TIME): data _null_;
MPRINT(DISTANCE_TIME): infile x recfm=f lrecl=1 end=eof;
MPRINT(DISTANCE_TIME): file z recfm=f lrecl=1;
MPRINT(DISTANCE_TIME): input @1 x $char1.;
MPRINT(DISTANCE_TIME): put @1 x $char1.;
MPRINT(DISTANCE_TIME): if eof;
MPRINT(DISTANCE_TIME): call symputx('filesize',_n_);
MPRINT(DISTANCE_TIME): run;
NOTE: Unable to connect to host www.google.com. Check validity of host name.
ERROR: Host name www.google.com not found.
NOTE: The file Z is:
Filename=/saswork/SAS_work41D5000062F8_lppma874.phx.aexp.com/#LN00107,
Owner Name=dcortell,Group Name=bis,
Access Permission=-rw-r--r--,
Last Modified=04Feb2016:10:08:32
NOTE: 0 records were written to the file Z.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

Before the filesize warning you hilighted, what cause (at least seems) the code not connection to the url is not described. The log just statesagain :" NOTE: Unable to connect to host www.google.com. Check validity of host name.
ERROR: Host name www.google.com not found."

 

Then follow the second error you mention(below, and still persist despite the duble quotes) , which I understand is not the root cause here

 

129      ! :comma12. text $30.; units    = scan
ERROR 24-2: Invalid value for the LRECL option.

WARNING: Apparent symbolic reference FILESIZE not resolved.

It seems that the main proble is due to the filename statement not abel to recognize the google Url

Super User
Posts: 11,343

Re: Connection to url via filename failed: ERROR: Host name www.google.com not found.

I get a "Connection has time out" error with that URL.

 

But we have so many layers of nanny ware installed that we often can't connect to government websites required for our work that may be interfering. I know that posting the URL in my browser I have to manually respond to at least one "warning" before it will go to the site. Perhaps that is related to the error message when using Filename x URL,

 

I don't think I can help with anything else at this time other than asking if before you created the macro code that you had a version that would pull the data without any macro references?

Contributor
Posts: 22

Re: Connection to url via filename failed: ERROR: Host name www.google.com not found.

Unluckly the code has been created by another user in the community in the link I posted above, so no idea about that.

 

True is that also with using the filename statement with only data step the error persist.

 

So wondering if there is something like a Fix or any proxy issue that is working here

 

Maybe there is soemone else which has managed to solve the problem in a company environment 

 

In any case thanks for the support Ballardw

Super User
Posts: 10,020

Re: Connection to url via filename failed: ERROR: Host name www.google.com not found.

If you could do not use httpS://..... which is encrypted connection. SAS might not handle it in this way .

Try htts://..........

 

http://www.google.com/maps/dir/&a1/&a2/?force=lite

Contributor
Posts: 22

Re: Connection to url via filename failed: ERROR: Host name www.google.com not found.

Hi Xia

 

Same errors here. So Would skip also this hypothesis. Thinking if it is not a proxy problem

 

D

Ask a Question
Discussion stats
  • 8 replies
  • 364 views
  • 2 likes
  • 3 in conversation