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.

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
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-2024.png

 

Secure your spot at the must-attend AI and analytics event of 2024: SAS Innovate 2024! Get ready for a jam-packed agenda featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events.

 

Register by March 1 to snag the Early Bird rate of just $695! Don't miss out on this exclusive offer. 

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 690 views
  • 0 likes
  • 3 in conversation