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.

Check out SAS Innovate on-demand content! Watch the main stage sessions, keynotes, and over 20 technical breakout sessions!

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 3 replies
  • 1067 views
  • 2 likes
  • 3 in conversation