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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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