Hello
As I know in SAS missing value for char is blank and missing value for numeric is period (.)
Why in this example missing value for char is also period (.)?
Why the value of the missing char is blank and not '.' ?
Data a;
Input X $ Y Z W;
cards;
M 56 68 89
F 33 60 .
M 45 91 .
. 35 65 .
;
run;
Because it's not a missing value. When reading character data into character variables, a dot is just a dot.
To correctly read empty data as missing character values, use the proper options in an infile statement, and deliver empty (non-existent) data:
data a;
infile cards dlm=' ' dsd truncover;
input X $ Y Z W;
cards;
M 56 68 89
F 33 60 .
M 45 91 .
35 65 .
;
run;
A line starting with a delimiter is now considered to start with a missing value; without the dsd option, the delimiter would be discarded.
The truncover option is necessary to deal with trailing missing values.
Because it's not a missing value. When reading character data into character variables, a dot is just a dot.
To correctly read empty data as missing character values, use the proper options in an infile statement, and deliver empty (non-existent) data:
data a;
infile cards dlm=' ' dsd truncover;
input X $ Y Z W;
cards;
M 56 68 89
F 33 60 .
M 45 91 .
35 65 .
;
run;
A line starting with a delimiter is now considered to start with a missing value; without the dsd option, the delimiter would be discarded.
The truncover option is necessary to deal with trailing missing values.
I think the question concerns the fact that SAS reads the dot for X variable in the last
row of data as a missing value although X is a character variable. In the resulting dataset,
X=" " and not the string ".".
@Tom gives an answer in the following thread (use the $char informat) :
You are right. That is a property of the default $w. informat, as mentioned in the relevant documentation:
Maxim 1
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.