Date: Mon, 25 Feb 2008 15:47:15 -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: How to right-align values when writing from a data set to a
In-Reply-To: <ipidnb1RQsOCu17aRVnzvQA@telenor.com>
Content-Type: text/plain; charset=ISO-8859-1
If you want to preserve the alignment use $CHAR informat.
data work.test;
*read character values and preserve alignment;
input a $char10.;
*234567890;
cards;
A
B
C
D
E
F
G
H
I
J
;;;;;
run;
proc print;
run;
I you want to right align when reading use -R format modifier.;
data work.test;
*read character values and preserve alignment;
input a $char10.-R;
cards;
Abcdefhij
B
C
D
E
F
G
H
I
J
;;;;;
run;
proc print;
run;
2008/2/25 Rune Runnestø <rune@fastlane.no>:
> I just write to inform you that the replacement of the dollar signs with the
> character format sign solved the problem.
>
> May be you might wonder why I don't use numeric informat for the variables I
> want to get right-aligned and character informat for the variables I want to
> get left-aligned ? Then I could have written them right back to file without
> any extra gambot. The reason is that some of the values on the disk file,
> which I read with the INFILE statement, have leading zeros. That's a sign of
> bad quality, which is what I intend to detect. If I had used numeric
> informat, SAS would have skipped the leading zeros, and I wouldn't have
> noticed them. It's not the data values in the SAS data set that is important
> to check, but the values on the file on the disk. So it's a point that the
> values in the data sets reflect what is on the file. Therefore, I have to
> use character informat. Then I use SAS to correct the values, and write the
> correct values back to file. If the values were originally right-aligned on
> the file, I have to use -R for those variables when writing them back to
> file. It is important that the values keep the same alignment on the
> corrected file.
>
> As far as I know, there is no chance to get a variable right-aligned in the
> SAS data set when it is read from the file with charcter informat. In case I
> have misunderstood or there is some technique that I am not aware of, I
> would appreciate to be informed.
>
> Rune
>
|