BookmarkSubscribeRSS Feed
scbamba
Calcite | Level 5

I have tried to locate our internal IP addresses throughout SAS but my code is not giving me observations.

 

FILENAME Signal '/folders/myshortcuts/SAS_Files/Test.csv';
Data IPData (Keep= ip Geoname_id);
Length ip $20 Geoname_id 8;
Infile Signal Firstobs=2;
Input ip $;
Array ipnew {4};
Do i=1 to 4;
ipnew{i} = scan(ip,i,'.');
End;
Geoname_id = ipnew {4} +
(ipnew {3}*256) +
(ipnew {2}*256*256) +
(ipnew {1}*256*256*256);
Run;
Quit;

 

Proc Geocode
Range
Out=Geo
Data=IPData
Addressvar=Geoname_id
Rangedata=CityBlock
Beginrangevar=startIpNum
Endrangevar=endipnum
Rangekeyvar=locId
Lookup=CityLocation
Lookupkeyvar=locId
Lookupyvar=latitude
Lookupxvar=longitude
Attributevar=(city, country);
Run;
Quit;

 

I get a table but no variable.

How can I fix it please ???

Thank you for your advice.

4 REPLIES 4
ballardw
Super User

@scbamba wrote:

I have tried to locate our internal IP addresses throughout SAS but my code is not giving me observations.

 

FILENAME Signal '/folders/myshortcuts/SAS_Files/Test.csv';
Data IPData (Keep= ip Geoname_id);
Length ip $20 Geoname_id 8;
Infile Signal Firstobs=2;
Input ip $;
Array ipnew {4};
Do i=1 to 4;
ipnew{i} = scan(ip,i,'.');
End;
Geoname_id = ipnew {4} +
(ipnew {3}*256) +
(ipnew {2}*256*256) +
(ipnew {1}*256*256*256);
Run;
Quit;

 

Proc Geocode
Range
Out=Geo
Data=IPData
Addressvar=Geoname_id
Rangedata=CityBlock
Beginrangevar=startIpNum
Endrangevar=endipnum
Rangekeyvar=locId
Lookup=CityLocation
Lookupkeyvar=locId
Lookupyvar=latitude
Lookupxvar=longitude
Attributevar=(city, country);
Run;
Quit;

 

I get a table but no variable.

How can I fix it please ???

Thank you for your advice.


There are so many data dependencies in geocoding look ups I can suggest a few things to look for.

First is the values of the LOOKUP= dataset and the range values used for comparison.

Then see if your Addressvar variable values (Geoname_id) match format and ranges as well.

 

You may also have a potential issue involving IPv6 values if any are present as your conversion is apparently for IPv4 addresses.

 

The quality of the look up data set is also of importance, perhaps none of your addresses actually match.

ChrisHemedinger
Community Manager

If you're working with IP addresses internal to a corporate network, not external on the internet, I don't think you'll find matches in any IP-address geo database.

Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.
scbamba
Calcite | Level 5
Good afternoon,

I convert the IP already to numerical value with the formula a*x3 + b*x2 + c*x + d.
But when I code the program it looks fine without error but the output is table with blank lines.
I am trying to figure it out and I will keep you updated.

Sincerely,

Sekou
ballardw
Super User

And what is in your lookup data set?

If there are no matches in the lookup data set you get no results.

Where did you get your lookup data set?

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 4 replies
  • 1007 views
  • 0 likes
  • 3 in conversation