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

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

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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

3 REPLIES 3
Tom
Super User Tom
Super User

You can use the $CHAR informat.

data check;

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

  put x= y=;

cards;

.

run;

x=  y=.

Haikuo
Onyx | Level 15

Use $char informat:

data have;

input  var$char1.;

cards;

a

.

b

;

proc print;run;

Regards,

Haikuo

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 1133 views
  • 6 likes
  • 4 in conversation