| Date: | Wed, 13 Feb 2008 17:24:51 -0500 |
| Reply-To: | "data _null_," <datanull@GMAIL.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | "data _null_," <datanull@GMAIL.COM> |
| Subject: | Re: question about input() |
|
| In-Reply-To: | <e5d433b5-6cdc-476b-859d-5ea4c77b826a@l16g2000hsh.googlegroups.com> |
| Content-Type: | text/plain; charset=WINDOWS-1252 |
Numeric values are converted to character using BEST12. So when you
read the value of A that is converted to character the first 3 columns
are blank and you just read blanks. You probably want PUT function
but that is unclear. The following tries to illustrate the effect of
the conversion to character with variable CC.
data try;
input a;
cards;
1
;
run;
data try;
set try;
length cc $12;
cc = a;
cc = translate(cc,'!',' '); *to see the spaces;
c=input(a,3.1); *reads first 3 columns of converted numeric;
d=put(a,3.1);
run;
proc contents; run;
proc print; run;
On Feb 13, 2008 5:07 PM, Mindy <master2005_sas@yahoo.com> wrote:
> Hey guys,
>
> I have a question about input() ___ maybe related with format/
> informat.
>
> Below is sample code:
>
> data try;
> input a;
> cards;
> 1
> ;
> run;
> data try;
> set try;
> c=input(a, 3.1);
> run;
> proc contents; run;
> proc print; run;
>
> And I got note as
>
> 20 set try;
> 21 c=input(a, 3.1);
> 22 run;
>
> NOTE: Numeric values have been converted to character values at the
> places given by: (Line):(Column).
> 21:12
>
> Output of proc contents as
>
> --Alphabetic List of Variables and Attributes-----
>
> # Variable Type
> Len Pos
>
> ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
> 1 a Num
> 8 0
> 2 c Num
> 8 8
>
> Output of proc print as
>
> Obs a c
>
> 1 1 .
>
>
> I don't understand why I get the note and missing value of c, which I
> thought it should be 1.0
>
> Many thanks.
>
> MIndy
>
|