Date: Thu, 21 Feb 2008 03:08:19 -0500
Reply-To: Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>
Subject: Re: Question of applying proc format
I'd suggest to create the format, like you did. Then use
proc format cntlout=a;
and have a look to the variables. Especially have a look to LENGTH which
is the default length for the format. If you have no OTHER branch and a
value which is not covered by the format, that value still is "formatted",
so at least the LENGTH, but no value (there is none available) is used.
On Wed, 20 Feb 2008 19:24:29 -0500, Ya Huang <ya.huang@AMYLIN.COM> wrote:
>"The default length of a format is the length of the longest formatted
>value", which in your case is 1.
>It basically says that put(a, $b.) is the same as put(a,$b1.). Since
>is not in the range list, put(a,$b.) will treat it as put(a,$1.), which
>result in a '2', or the first character of a. To fix it:
>or add other=' ' (or other=[$10.]) in your proc format.
> value $ b '12345'='1'
> other=' ' /* other=[$10.] */
>On Wed, 20 Feb 2008 15:57:07 -0800, Mindy <master2005_sas@YAHOO.COM>
>>Below is my code and output. I really feel confuse why "223456" is
>>formated to "2", which I think should be "223456". Many thanks. ___
>> length a $6;
>> input a;
>> value $ b '12345'='1'
>> set try;
>> length c $6;
>> c=put(a, $b.);
>>proc print; run;
>>The SAS System 15:11 Wednesday, February 20, 2008 6
>> Obs a
>> 1 12345
>> 2 223456
>> 3 12