Hello
I am trying to run a code which givers error particular values of zipcode.
data _null_;
dist=zipcitydistance(36310,36061);
run;
The error in the log is
NOTE: ZIP code value 36310 could not be found in SASHELP.ZIPCODE.
NOTE: Invalid argument to function ZIPCITYDISTANCE('36310','36061') at line 27 column 6.
dist=. _ERROR_=1 _N_=1
NOTE: Mathematical operations could not be performed at the following places. The results of the operations have been set to
missing values.
Each place is given by: (Number of times) at (Line):(Column).
1 at 27:6
If I change the order of zipcode in the function taking 36061 first, then the error would be
24
25 GOPTIONS ACCESSIBLE;
26 data _null_;
27 dist=zipcitydistance(36061,36310);
28 run;
NOTE: ZIP code value 36061 could not be found in SASHELP.ZIPCODE.
NOTE: Invalid argument to function ZIPCITYDISTANCE(36061,36310) at line 27 column 6.
dist=. _ERROR_=1 _N_=1
NOTE: Mathematical operations could not be performed at the following places. The results of the operations have been set to
missing values.
Each place is given by: (Number of times) at (Line):(Column).
1 at 27:6
The server has been updated for the latest values of zipcodes.
Looks like I missing something. Can anybody help?
Suggest looking at the records in sashelp.zipcode to make sure the zip codes are there:
proc print data=sashelp.zipcode;
var zip ;
where zip in (36061 36310) ;
run ;
I have them in my data, and your code runs fine:
16 data _null_; 17 dist=zipcitydistance(36310,36061); 18 put dist= ; 19 run; dist=41.5
Suggest looking at the records in sashelp.zipcode to make sure the zip codes are there:
proc print data=sashelp.zipcode;
var zip ;
where zip in (36061 36310) ;
run ;
I have them in my data, and your code runs fine:
16 data _null_; 17 dist=zipcitydistance(36310,36061); 18 put dist= ; 19 run; dist=41.5
To make sure you have the most current zipcode data set, see the following:
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.