From: Jack Kelly on
<snip>
Yes, use scan,input,put can do it:

1 data _null_;
2 iphx='0xC0.0x00.0x02.0xEB';
3 ipdec1=put(input(scan(scan(iphx,1,'.'),2,'x'),hex.),best.);
</snip>

My mistake and thanks for the reply. I should have stated that the number
is hex with no dots, e.g. x'99aa2233'. It is an IBM format that they use
in most of their accounting type data. So I can't see how I can SCAN and
SUBSTR[N] only seems to work well with characters.
From: Nathaniel Wooding on
Jack

Just a swag but could you use a picture format?

Nat Wooding (who has not written a picture format in decades)

-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L(a)LISTSERV.UGA.EDU] On Behalf Of Jack Kelly
Sent: Friday, February 26, 2010 1:05 PM
To: SAS-L(a)LISTSERV.UGA.EDU
Subject: How to - Hex IP address to dotted decimal

I know that I can input each hex character of a V4 IP address individually
and define them as PIB3. and make a dotted decimal IP address. What I'm
curious is, can I input the four character hex IP address and somehow
convert that to a decimal numbers? I've used SCAN and INPUT to go the
other way, dotted decimal to Hex buy ....


Jack Kelly
202-502-2390 (Office)
CONFIDENTIALITY NOTICE: This electronic message contains
information which may be legally confidential and or privileged and
does not in any case represent a firm ENERGY COMMODITY bid or offer
relating thereto which binds the sender without an additional
express written confirmation to that effect. The information is
intended solely for the individual or entity named above and access
by anyone else is unauthorized. If you are not the intended
recipient, any disclosure, copying, distribution, or use of the
contents of this information is prohibited and may be unlawful. If
you have received this electronic transmission in error, please
reply immediately to the sender that you have received the message
in error, and delete it. Thank you.
From: Ya Huang on
Yes, use scan,input,put can do it:

1 data _null_;
2 iphx='0xC0.0x00.0x02.0xEB';
3 ipdec1=put(input(scan(scan(iphx,1,'.'),2,'x'),hex.),best.);
4 ipdec2=put(input(scan(scan(iphx,2,'.'),2,'x'),hex.),best.);
5 ipdec3=put(input(scan(scan(iphx,3,'.'),2,'x'),hex.),best.);
6 ipdec4=put(input(scan(scan(iphx,4,'.'),2,'x'),hex.),best.);
7 ipdec=compress(ipdec1||'.'||ipdec2||'.'||ipdec3||'.'||ipdec4);
8 put ipdec;
9 run;

192.0.2.235
NOTE: DATA statement used (Total process time):


On Fri, 26 Feb 2010 13:04:31 -0500, Jack Kelly
<John_J_Kelly(a)AO.USCOURTS.GOV> wrote:

>I know that I can input each hex character of a V4 IP address individually
>and define them as PIB3. and make a dotted decimal IP address. What I'm
>curious is, can I input the four character hex IP address and somehow
>convert that to a decimal numbers? I've used SCAN and INPUT to go the
>other way, dotted decimal to Hex buy ....
>
>
>Jack Kelly
>202-502-2390 (Office)
From: Joe Matise on
You should still be able to use SUBSTR, just use PUT [into PIB.] inside the
substr to make sure it's well behaved.

-Joe

On Fri, Feb 26, 2010 at 12:34 PM, Jack Kelly
<John_J_Kelly(a)ao.uscourts.gov>wrote:

> <snip>
> Yes, use scan,input,put can do it:
>
> 1 data _null_;
> 2 iphx='0xC0.0x00.0x02.0xEB';
> 3 ipdec1=put(input(scan(scan(iphx,1,'.'),2,'x'),hex.),best.);
> </snip>
>
> My mistake and thanks for the reply. I should have stated that the number
> is hex with no dots, e.g. x'99aa2233'. It is an IBM format that they use
> in most of their accounting type data. So I can't see how I can SCAN and
> SUBSTR[N] only seems to work well with characters.
>
From: Ya Huang on
Then use $hex. format to convert it first:

151 data _null_;
152 iphx='99aa2233'x;
153 iphxc=put(iphx,$hex.);
154 ipdec1=put(input(substr(iphxc,1,2),hex.),best.);
155 ipdec2=put(input(substr(iphxc,3,2),hex.),best.);
156 ipdec3=put(input(substr(iphxc,5,2),hex.),best.);
157 ipdec4=put(input(substr(iphxc,7,2),hex.),best.);
158 ipdec=compress(ipdec1||'.'||ipdec2||'.'||ipdec3||'.'||ipdec4);
159 put ipdec;
160 run;

153.170.34.51


On Fri, 26 Feb 2010 13:34:42 -0500, Jack Kelly
<John_J_Kelly(a)AO.USCOURTS.GOV> wrote:

><snip>
>Yes, use scan,input,put can do it:
>
>1 data _null_;
>2 iphx='0xC0.0x00.0x02.0xEB';
>3 ipdec1=put(input(scan(scan(iphx,1,'.'),2,'x'),hex.),best.);
></snip>
>
>My mistake and thanks for the reply. I should have stated that the number
>is hex with no dots, e.g. x'99aa2233'. It is an IBM format that they use
>in most of their accounting type data. So I can't see how I can SCAN and
>SUBSTR[N] only seems to work well with characters.