BookmarkSubscribeRSS Feed
prolifious
Obsidian | Level 7

I have a CSV that includes a single column of all IP addresses.  I'd like to build another column by determining a domain name from the IPs and filling that new column, with the determined domain name.  

 

I can do this no problem in powershell or a python program, but I can't see to figure out if it's possible with SAS, where i need to do my work.

 

Is this possible with SAS?  I've seen proc http, but i couldn't find any indication that it's possible there.

 

anything info on here will help, I seem to have hit a wall with this.

 

thanks

3 REPLIES 3
ChrisNZ
Tourmaline | Level 20

How do you do it in python? You need to query a DNS somehow don't you?

prolifious
Obsidian | Level 7

this is a python method for getting a domain from an ip:

 

import socket

try:
a = '52.216.64.218'
b = socket.gethostbyaddr(a)
print(b)
except socket.error:
b = 'No Host Found'
print(b)

 

it's easy to do it in reverse as well.

 

So, any update on this?  is it possible through PROC HHTP somehow?  speaking of which, is there any good documentaiton/whitepapers on PROC HTTP?  i could only find limited resources on it.

 

thanks

ChrisHemedinger
Community Manager

PROC HTTP documentation is hereI also have a series of blog articles about various use cases for PROC HTTP.

 

gethostbyaddr and gethostbyname are functions that are built into the operating system.  getnameinfo is actually the preferred method to use now.   Some programming languages expose these as functions in their own syntax, but I haven't found where SAS does that.  

 

I think it would be possible to call this using CALL MODULE if you know the external library (DLL) to reference.  It's a little tricky to set up, and I don't have a working example handy.  It would be different between Linux and Windows.

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 3 replies
  • 1799 views
  • 2 likes
  • 3 in conversation