Wednesday, February 10, 2016

$w. vs. $CHARw.

$w. is the default informat for character variable. It will convert single period to a blank automatically. To fix it, we can use $CHARW. alternatively.

Below are the difference in SAS doc:
The $w. informat is almost identical to the $CHARw. informat. However, $CHARw. does not trim leading blanks nor does it convert a single period in an input field to a blank, while $w. does both.
data num;
   infile datalines dlmstr="|" missover;

   length x $10;
   attrib y length=$10 informat=$char10.;
   length z $10;

   input x y z;
   put x= y= z=; * y is period while z is blank;
   datalines;
1|.|.
;