BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
thesasuser
Lapis Lazuli | Level 10

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Quentin
Super User

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

View solution in original post

2 REPLIES 2
Quentin
Super User

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
Kathryn_SAS
SAS Employee

To make sure you have the most current zipcode data set, see the following:

https://sas.service-now.com/csm/en/how-to-replace-the-sashelp-zipcode-data-set?id=kb_article_view&sy...

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 367 views
  • 0 likes
  • 3 in conversation