BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Ronein
Meteorite | Level 14

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; 
1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

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.

View solution in original post

6 REPLIES 6
Kurt_Bremser
Super User

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.

gamotte
Rhodochrosite | Level 12

@Kurt_Bremser ,

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 ".".

gamotte
Rhodochrosite | Level 12

@Tom gives an answer in the following thread (use the $char informat) :

 

https://communities.sas.com/t5/SAS-Programming/how-to-read-a-dot-or-fullstop-in-text-file/td-p/24923...

Kurt_Bremser
Super User

You are right. That is a property of the default $w. informat, as mentioned in the relevant documentation:

 

The $w. informat trims leading blanks and left-aligns the values before storing the text. In addition, if a field contains only blanks and a single period, $w. converts the period to a blank because it interprets the period as a missing value. The $w. informat treats two or more periods in a field as character data.

 

gamotte
Rhodochrosite | Level 12

Maxim 1 Smiley Happy

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 2236 views
  • 1 like
  • 3 in conversation