Help using Base SAS procedures

period as missing character

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 12
Accepted Solution

period as missing character

Hello all:

  I want to read some characters into SAS from a text file. One record has a value '. ' which is a period followed by a space. However, SAS read treat it as missing. My understanding is that period is treated as missing for numeric but  not for character. So why this is the case and how to read a value like that as it is? For example, if this is my input file mydoc.txt:

a

.

b

this is my SAS:

data mydoc;
infile 'mydoc.txt';
input val$;

proc print data=mydoc;
run;

The result will be:

 

  obs val

  1      a
  2
  3      b

Any suggestions?

Thanks,

Peter


Accepted Solutions
Solution
‎04-04-2012 11:24 AM
Super User
Super User
Posts: 7,054

Re: period as missing character

Posted in reply to tradepeter

You can use the $CHAR informat.

data check;

  input @1 x $1. @1 y $char1.;

  put x= y=;

cards;

.

run;

x=  y=.

View solution in original post


All Replies
Regular Contributor
Posts: 233
Solution
‎04-04-2012 11:24 AM
Super User
Super User
Posts: 7,054

Re: period as missing character

Posted in reply to tradepeter

You can use the $CHAR informat.

data check;

  input @1 x $1. @1 y $char1.;

  put x= y=;

cards;

.

run;

x=  y=.

Respected Advisor
Posts: 3,156

period as missing character

Posted in reply to tradepeter

Use $char informat:

data have;

input  var$char1.;

cards;

a

.

b

;

proc print;run;

Regards,

Haikuo

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 265 views
  • 6 likes
  • 4 in conversation