From: Joe Matise on
The OP tried that already. I suspect he has a nonprinting character in
there somewhere; COMPRESS removes that, and he confirmed offline that
solution worked.

Of course if one is curious what those characters are, could always use the
$HEX. informat to see what they are, right?

-Joe

On Thu, Feb 18, 2010 at 11:03 AM, Nathaniel Wooding <
nathaniel.wooding(a)dom.com> wrote:

> I agree with Gerhard about avoiding short informats. A further solution
> would be to simply use the Best. Informat with no length specified.
>
>
> Data t;
> cnum = ' 12345678';
> num = input( cnum , best. );
> run;
>
>
> Nat Wooding
>
> -----Original Message-----
> From: SAS(r) Discussion [mailto:SAS-L(a)LISTSERV.UGA.EDU] On Behalf Of Tom
> White
> Sent: Thursday, February 18, 2010 10:52 AM
> To: SAS-L(a)LISTSERV.UGA.EDU
> Subject: Convert Character into numeric
>
> Hello SAS-L,
>
> I am strugling with converting an ACCOUNT_NUMBER variable with format and
> informat $9.
> Wjen I count the length of this variable it varies from 4 digits to 9
> digits.
> Yet, when I look at a 4-digit account_number [L=length(account_number);
> L=4]
> the actual account_number has only 3 digits. Similarly for the 9-digit. The
> actual account_number
> has only 8 digits.
>
> This leads me to believe that maybe we have a trailing zero in
> account_number.
>
> I try to conver the account_number (say, account_number=12345678 which has
> length=9 and not 8
> according to above remark).
>
> ACCT_NBR=input(account_number, best.)
>
> This doesn't convert the account numbers.
> Instead, I get . for all of them except for the last observation in the
> account_umber (wired ???)
>
> when I try
>
> ACCT_NBR=input(account_number, 9.) [The maximum lenght L=9 per note above]
> I get missing account numbers again (.) except for the last obs in
> account_number variable (wired ???)
>
> when I try
>
> ACCT_NBR=input(account_number, 8.) the accounts are converted but not all.
>
> SAS picks and chooses which ones to convert !
>
> It appears though that the 8-digit acount numbers (L=9) are being
> converted.
>
> Those account numbers with fewer than 8-digits, some are convertd, som are
> not convertd.
>
> What's going on?
>
> tom
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> =
> 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: Gerhard Hellriegel on
seems that there is a default for best. I get the following with very long
numbers:

23 data _null_;
24 a_c = "12345678953535350";
25 a_n = input(a_c,best.);
26 put a_c=;
27 put a_n=;
28 run;

a_c=12345678953535350
a_n=123456789535


anyway tehre is no good way to use very long numbers as keys, e.g as a
accounting number:

data _null_;
a_c = "1234567890123456789";
a_n = input(a_c,32.);
put a_c;
put a_n 19.;
run;

the result is:

1234567890123456789
1234567890123456768


That is simply a problem of the number of significant digits in a 8-byte
numeric variable. It is too long!
If it is necessary to have longer account_numbers, you must use a
character variable for that. In that case it might be also a better way to
make it shorter and use a, b, c, ... for making it unique.
Or you start with numerics (it's easier to generate a unique key by simply
adding 1....) and hope that until you reach the limit there is a SI-
solution for the "short" numbers, e.g. a 16- or 32-byte representation of
numbers. Think 16 byte would be very much, 1 byte for exponent, 15*8-1 bit
for the number = 2**120-1 as biggest number ... SAS says that this is
something around 1.3e36 so I think 35 digits should be reliable then. Ok,
to be more sure, perhaps 32 byte, 2 for exponent, 30 for mantissa (30*8-1
means 1.7e72, so 70 digits should be ok, enough for the next few years to
contain the national dept of Germany - not sure about that...)


Gerhard




On Thu, 18 Feb 2010 12:03:19 -0500, Nathaniel Wooding
<nathaniel.wooding(a)DOM.COM> wrote:

>I agree with Gerhard about avoiding short informats. A further solution
would be to simply use the Best. Informat with no length specified.
>
>
>Data t;
>cnum = ' 12345678';
>num = input( cnum , best. );
>run;
>
>
>Nat Wooding
>
>-----Original Message-----
>From: SAS(r) Discussion [mailto:SAS-L(a)LISTSERV.UGA.EDU] On Behalf Of Tom
White
>Sent: Thursday, February 18, 2010 10:52 AM
>To: SAS-L(a)LISTSERV.UGA.EDU
>Subject: Convert Character into numeric
>
>Hello SAS-L,
>
>I am strugling with converting an ACCOUNT_NUMBER variable with format and
informat $9.
>Wjen I count the length of this variable it varies from 4 digits to 9
digits.
>Yet, when I look at a 4-digit account_number [L=length(account_number);
L=4]
>the actual account_number has only 3 digits. Similarly for the 9-digit.
The actual account_number
>has only 8 digits.
>
>This leads me to believe that maybe we have a trailing zero in
account_number.
>
>I try to conver the account_number (say, account_number=12345678 which
has length=9 and not 8
>according to above remark).
>
>ACCT_NBR=input(account_number, best.)
>
>This doesn't convert the account numbers.
>Instead, I get . for all of them except for the last observation in the
account_umber (wired ???)
>
>when I try
>
>ACCT_NBR=input(account_number, 9.) [The maximum lenght L=9 per note above]
>I get missing account numbers again (.) except for the last obs in
account_number variable (wired ???)
>
>when I try
>
>ACCT_NBR=input(account_number, 8.) the accounts are converted but not all.
>
>SAS picks and chooses which ones to convert !
>
>It appears though that the 8-digit acount numbers (L=9) are being
converted.
>
>Those account numbers with fewer than 8-digits, some are convertd, som
are not convertd.
>
>What's going on?
>
>tom
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>=
>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: Joe Matise on
BEST. is really BEST12., if I remember correctly.

-Joe

On Thu, Feb 18, 2010 at 11:33 AM, Gerhard Hellriegel <
gerhard.hellriegel(a)t-online.de> wrote:

> seems that there is a default for best. I get the following with very long
> numbers:
>
> 23 data _null_;
> 24 a_c = "12345678953535350";
> 25 a_n = input(a_c,best.);
> 26 put a_c=;
> 27 put a_n=;
> 28 run;
>
> a_c=12345678953535350
> a_n=123456789535
>
>
> anyway tehre is no good way to use very long numbers as keys, e.g as a
> accounting number:
>
> data _null_;
> a_c = "1234567890123456789";
> a_n = input(a_c,32.);
> put a_c;
> put a_n 19.;
> run;
>
> the result is:
>
> 1234567890123456789
> 1234567890123456768
>
>
> That is simply a problem of the number of significant digits in a 8-byte
> numeric variable. It is too long!
> If it is necessary to have longer account_numbers, you must use a
> character variable for that. In that case it might be also a better way to
> make it shorter and use a, b, c, ... for making it unique.
> Or you start with numerics (it's easier to generate a unique key by simply
> adding 1....) and hope that until you reach the limit there is a SI-
> solution for the "short" numbers, e.g. a 16- or 32-byte representation of
> numbers. Think 16 byte would be very much, 1 byte for exponent, 15*8-1 bit
> for the number = 2**120-1 as biggest number ... SAS says that this is
> something around 1.3e36 so I think 35 digits should be reliable then. Ok,
> to be more sure, perhaps 32 byte, 2 for exponent, 30 for mantissa (30*8-1
> means 1.7e72, so 70 digits should be ok, enough for the next few years to
> contain the national dept of Germany - not sure about that...)
>
>
> Gerhard
>
>
>
>
> On Thu, 18 Feb 2010 12:03:19 -0500, Nathaniel Wooding
> <nathaniel.wooding(a)DOM.COM> wrote:
>
> >I agree with Gerhard about avoiding short informats. A further solution
> would be to simply use the Best. Informat with no length specified.
> >
> >
> >Data t;
> >cnum = ' 12345678';
> >num = input( cnum , best. );
> >run;
> >
> >
> >Nat Wooding
> >
> >-----Original Message-----
> >From: SAS(r) Discussion [mailto:SAS-L(a)LISTSERV.UGA.EDU] On Behalf Of Tom
> White
> >Sent: Thursday, February 18, 2010 10:52 AM
> >To: SAS-L(a)LISTSERV.UGA.EDU
> >Subject: Convert Character into numeric
> >
> >Hello SAS-L,
> >
> >I am strugling with converting an ACCOUNT_NUMBER variable with format and
> informat $9.
> >Wjen I count the length of this variable it varies from 4 digits to 9
> digits.
> >Yet, when I look at a 4-digit account_number [L=length(account_number);
> L=4]
> >the actual account_number has only 3 digits. Similarly for the 9-digit.
> The actual account_number
> >has only 8 digits.
> >
> >This leads me to believe that maybe we have a trailing zero in
> account_number.
> >
> >I try to conver the account_number (say, account_number=12345678 which
> has length=9 and not 8
> >according to above remark).
> >
> >ACCT_NBR=input(account_number, best.)
> >
> >This doesn't convert the account numbers.
> >Instead, I get . for all of them except for the last observation in the
> account_umber (wired ???)
> >
> >when I try
> >
> >ACCT_NBR=input(account_number, 9.) [The maximum lenght L=9 per note above]
> >I get missing account numbers again (.) except for the last obs in
> account_number variable (wired ???)
> >
> >when I try
> >
> >ACCT_NBR=input(account_number, 8.) the accounts are converted but not all.
> >
> >SAS picks and chooses which ones to convert !
> >
> >It appears though that the 8-digit acount numbers (L=9) are being
> converted.
> >
> >Those account numbers with fewer than 8-digits, some are convertd, som
> are not convertd.
> >
> >What's going on?
> >
> >tom
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >=
> >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: Dianne Rhodes on
On Thu, 18 Feb 2010 11:36:37 -0600, Joe Matise <snoopy369(a)GMAIL.COM> wrote:

>BEST. is really BEST12., if I remember correctly.
>
>-Joe

Yeah, the default for BEST is BEST12. I would avoid using it as it can
produce "unexpected" results.

Dianne @ census
From: Tom White on
Thank you all for your inputs:

joe
jim
gerhard
nat

tom







-----Original Message-----
From: Joe Matise <snoopy369(a)GMAIL.COM>
To: SAS-L(a)LISTSERV.UGA.EDU
Sent: Thu, Feb 18, 2010 11:36 am
Subject: Re: Convert Character into numeric


BEST. is really BEST12., if I remember correctly.
-Joe
On Thu, Feb 18, 2010 at 11:33 AM, Gerhard Hellriegel <
erhard.hellriegel(a)t-online.de> wrote:
> seems that there is a default for best. I get the following with very lo=
ng
numbers:

23 data _null_;
24 a_c =3D "12345678953535350";
25 a_n =3D input(a_c,best.);
26 put a_c=3D;
27 put a_n=3D;
28 run;

a_c=3D12345678953535350
a_n=3D123456789535


anyway tehre is no good way to use very long numbers as keys, e.g as a
accounting number:

data _null_;
a_c =3D "1234567890123456789";
a_n =3D input(a_c,32.);
put a_c;
put a_n 19.;
run;

the result is:

1234567890123456789
1234567890123456768


That is simply a problem of the number of significant digits in a 8-byte
numeric variable. It is too long!
If it is necessary to have longer account_numbers, you must use a
character variable for that. In that case it might be also a better way=
to
make it shorter and use a, b, c, ... for making it unique.
Or you start with numerics (it's easier to generate a unique key by simpl=
y
adding 1....) and hope that until you reach the limit there is a SI-
solution for the "short" numbers, e.g. a 16- or 32-byte representation of
numbers. Think 16 byte would be very much, 1 byte for exponent, 15*8-1 bi=
t
for the number =3D 2**120-1 as biggest number ... SAS says that this is
something around 1.3e36 so I think 35 digits should be reliable then. Ok,
to be more sure, perhaps 32 byte, 2 for exponent, 30 for mantissa (30*8-1
means 1.7e72, so 70 digits should be ok, enough for the next few years to
contain the national dept of Germany - not sure about that...)


Gerhard




On Thu, 18 Feb 2010 12:03:19 -0500, Nathaniel Wooding
<nathaniel.wooding(a)DOM.COM> wrote:

>I agree with Gerhard about avoiding short informats. A further solution
would be to simply use the Best. Informat with no length specified.
>
>
>Data t;
>cnum =3D ' 12345678';
>num =3D input( cnum , best. );
>run;
>
>
>Nat Wooding
>
>-----Original Message-----
>From: SAS(r) Discussion [mailto:SAS-L(a)LISTSERV.UGA.EDU] On Behalf Of Tom
White
>Sent: Thursday, February 18, 2010 10:52 AM
>To: SAS-L(a)LISTSERV.UGA.EDU
>Subject: Convert Character into numeric
>
>Hello SAS-L,
>
>I am strugling with converting an ACCOUNT_NUMBER variable with format an=
d
informat $9.
>Wjen I count the length of this variable it varies from 4 digits to 9
digits.
>Yet, when I look at a 4-digit account_number [L=3Dlength(account_number)=
;
L=3D4]
>the actual account_number has only 3 digits. Similarly for the 9-digit.
The actual account_number
>has only 8 digits.
>
>This leads me to believe that maybe we have a trailing zero in
account_number.
>
>I try to conver the account_number (say, account_number=3D12345678 which
has length=3D9 and not 8
>according to above remark).
>
>ACCT_NBR=3Dinput(account_number, best.)
>
>This doesn't convert the account numbers.
>Instead, I get . for all of them except for the last observation in the
account_umber (wired ???)
>
>when I try
>
>ACCT_NBR=3Dinput(account_number, 9.) [The maximum lenght L=3D9 per note=
above]
>I get missing account numbers again (.) except for the last obs in
account_number variable (wired ???)
>
>when I try
>
>ACCT_NBR=3Dinput(account_number, 8.) the accounts are converted but not=
all.
>
>SAS picks and chooses which ones to convert !
>
>It appears though that the 8-digit acount numbers (L=3D9) are being
converted.
>
>Those account numbers with fewer than 8-digits, some are convertd, som
are not convertd.
>
>What's going on?
>
>tom
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>=3D
>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.










-----Original Message-----
From: Joe Matise <snoopy369(a)GMAIL.COM>
To: SAS-L(a)LISTSERV.UGA.EDU
Sent: Thu, Feb 18, 2010 11:36 am
Subject: Re: Convert Character into numeric


BEST. is really BEST12., if I remember correctly.
-Joe
On Thu, Feb 18, 2010 at 11:33 AM, Gerhard Hellriegel <
erhard.hellriegel(a)t-online.de> wrote:
> seems that there is a default for best. I get the following with very lo=
ng
numbers:

23 data _null_;
24 a_c =3D "12345678953535350";
25 a_n =3D input(a_c,best.);
26 put a_c=3D;
27 put a_n=3D;
28 run;

a_c=3D12345678953535350
a_n=3D123456789535


anyway tehre is no good way to use very long numbers as keys, e.g as a
accounting number:

data _null_;
a_c =3D "1234567890123456789";
a_n =3D input(a_c,32.);
put a_c;
put a_n 19.;
run;

the result is:

1234567890123456789
1234567890123456768


That is simply a problem of the number of significant digits in a 8-byte
numeric variable. It is too long!
If it is necessary to have longer account_numbers, you must use a
character variable for that. In that case it might be also a better way=
to
make it shorter and use a, b, c, ... for making it unique.
Or you start with numerics (it's easier to generate a unique key by simpl=
y
adding 1....) and hope that until you reach the limit there is a SI-
solution for the "short" numbers, e.g. a 16- or 32-byte representation of
numbers. Think 16 byte would be very much, 1 byte for exponent, 15*8-1 bi=
t
for the number =3D 2**120-1 as biggest number ... SAS says that this is
something around 1.3e36 so I think 35 digits should be reliable then. Ok,
to be more sure, perhaps 32 byte, 2 for exponent, 30 for mantissa (30*8-1
means 1.7e72, so 70 digits should be ok, enough for the next few years to
contain the national dept of Germany - not sure about that...)


Gerhard




On Thu, 18 Feb 2010 12:03:19 -0500, Nathaniel Wooding
<nathaniel.wooding(a)DOM.COM> wrote:

>I agree with Gerhard about avoiding short informats. A further solution
would be to simply use the Best. Informat with no length specified.
>
>
>Data t;
>cnum =3D ' 12345678';
>num =3D input( cnum , best. );
>run;
>
>
>Nat Wooding
>
>-----Original Message-----
>From: SAS(r) Discussion [mailto:SAS-L(a)LISTSERV.UGA.EDU] On Behalf Of Tom
White
>Sent: Thursday, February 18, 2010 10:52 AM
>To: SAS-L(a)LISTSERV.UGA.EDU
>Subject: Convert Character into numeric
>
>Hello SAS-L,
>
>I am strugling with converting an ACCOUNT_NUMBER variable with format an=
d
informat $9.
>Wjen I count the length of this variable it varies from 4 digits to 9
digits.
>Yet, when I look at a 4-digit account_number [L=3Dlength(account_number)=
;
L=3D4]
>the actual account_number has only 3 digits. Similarly for the 9-digit.
The actual account_number
>has only 8 digits.
>
>This leads me to believe that maybe we have a trailing zero in
account_number.
>
>I try to conver the account_number (say, account_number=3D12345678 which
has length=3D9 and not 8
>according to above remark).
>
>ACCT_NBR=3Dinput(account_number, best.)
>
>This doesn't convert the account numbers.
>Instead, I get . for all of them except for the last observation in the
account_umber (wired ???)
>
>when I try
>
>ACCT_NBR=3Dinput(account_number, 9.) [The maximum lenght L=3D9 per note=
above]
>I get missing account numbers again (.) except for the last obs in
account_number variable (wired ???)
>
>when I try
>
>ACCT_NBR=3Dinput(account_number, 8.) the accounts are converted but not=
all.
>
>SAS picks and chooses which ones to convert !
>
>It appears though that the 8-digit acount numbers (L=3D9) are being
converted.
>
>Those account numbers with fewer than 8-digits, some are convertd, som
are not convertd.
>
>What's going on?
>
>tom
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>=3D
>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.
First  |  Prev  |  Next  |  Last
Pages: 1 2 3
Prev: Convert Character into numeric
Next: Date Format issue