In reply to Ethan.

Ethan,

When I did this years ago for IPv4, I used the MaxMind data and the IP ranges mapped to countries. I made a custom format in SAS that would map an IP address based on the range to a country.

DATA WORK._EG_CFMT;
SET IP2LOC.CITYBLOCKS /* from MaxMind macro */
(KEEP=startIpNum endIpNum locId
RENAME=(startIpNum=start endIpNum=end locId=label));
RETAIN fmtname "ip2loc" type "N";
RUN;

/* --------------------------------------------------------------------
Creates a new format based on the data values contained within the
source data set.
-------------------------------------------------------------------- */
PROC FORMAT LIBRARY=WORK CNTLIN=WORK._EG_CFMT;
RUN;

But if I were doing this today, I'd use the technique shared by Agata -- which covers IPv6 as well.