Date: Tue, 21 Dec 2004 11:37:48 -0500
Reply-To: Igor Kurbeko <ikurbeko@ATHEROGENICS.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Igor Kurbeko <ikurbeko@ATHEROGENICS.COM>
Subject: Re: Display trailing blanks in a variable (proc print and
resulting html file) ???
Content-Type: text/plain; charset="us-ascii"
Chang, actually that's what I'm trying to do:
data one;
format t1 $20. ;
t1="7 ";
ptid=111;
run;
proc print data=one;
run;
ods html body='h:/deleteme.html' ;
proc print data=one noobs style(data)=[asis=on];
run;
ods html close;
The problem is that the resulting html file does not have trailing
blanks in the variable t1.
Any ideas?
Igor Kurbeko
Clinical Programmer Analyst
678 336 4328
ikurbeko@atherogenics.com
If you torture data sufficiently, it will confess to almost anything.
-----Original Message-----
From: Chang Y. Chung [mailto:chang_y_chung@HOTMAIL.COM]
Sent: Tuesday, December 21, 2004 11:27 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: Display trailing blanks in a variable (proc print) ???
On Tue, 21 Dec 2004 10:57:48 -0500, Igor Kurbeko
<ikurbeko@ATHEROGENICS.COM> wrote:
>Hi, guys.
>
>I have a variable with trailing blanks.
...
Hi, Igor,
We all do. In sas, all character type variables have trailing blanks,
once
stored -- since they are fixed length strings right-padded with blank
characters.
You can force proc print to display trailing blanks by having a pseudo-
observation with a non-blank value of full length of the variable, like:
data one;
length c $10;
/* this is a dummy obs */
c = "----+----1";
output;
c = "A";
output;
run;
proc print data=one;
run;
/* on lst
Obs c
1 ----+----1
2 A
*/
It is also conceivable to put a non-blank character at the end
(especially
an invisible character like '00'x), but I don't recommend it -- this is
a
*very* dangerous practice.
data two;
length c $10;
c = "A";
if substr(c,10,1)="" then substr(c,10,1) = '*'; /* '00'x */
run;
proc print data=two;
run;
/* on lst
Obs c
1 A *
*/
Cheers,
Chang