BookmarkSubscribeRSS Feed
braveblade
Fluorite | Level 6

I tried to read the following data into SAS:

 

A.Jones       1-1-60         9-15-96      18JUN12
R.Grandage 03/18/1988 31-10-2007 5jul2012
K.Kaminaka 052903       2012024     12-MAR-12

 

data library;

infile 'C:\MyRawData\Library.dat' truncover;

informat name $10.;

informat birthday mmddyy6.;

informat issued anydtdte5.;

informat returned anydtdte5.;

input name $ +1 birthday +1 issueddate + 1 returneddate;

format returned date9.;

run;

 

You can see in the informat I defined the length of the dates are way less than the actual date legnth. But SAS is still reading the data fine. Can anyone explain why? Thanks!

3 REPLIES 3
Ksharp
Super User

Not test .Can you try:

 

 

data library;

infile 'C:\MyRawData\Library.dat' truncover dlm=' '; /*need specify delimiter here*/

 

input name : $10.  birthday : mmddyy6. issueddate : anydtdte5. returneddate : anydtdte5.;

format returned date9.;

run;

Tom
Super User Tom
Super User

Mainly because you are using a LIST mode INPUT statement. That is what it does. It skips over the extra spaces.

If you want it to only input exactly the format you specified then you need to use a FORMATTED mode INPUT statement.

 

Also why did you include cursor movement commands +1 ?  

That could potentially move the cursor past the first character of the next value.  So it could read '11JAN2016' as '1JAN2016'.

 

 

 

ballardw
Super User

I disbelieve that issuedate and returneddate were read correctly. You specified different variable names for  informat statements.

And with the corrected names the valus for issuedate and returneddate are not correct for the second record because of the +1.

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
  • 802 views
  • 0 likes
  • 4 in conversation