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.
@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.
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.
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 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.