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.

Register for SAS Innovate 2025!! The premier event for SAS users, May 6-9 in Orlando FL. Sign up now for the best deals!

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 1382 views
  • 2 likes
  • 3 in conversation