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

Hello All

I am learning sas now . I am practicing some small projects posted online.

This is one clinical trials project.

rawdate

PatientDose Date
00101Jan2003
00102Jan2003
00215Mar2003
00201Mar2003
00301Apr2003
00419Mar2003

I created dataset using this code in sas

data dose;

infile 'C:\Users\Contacts\Desktop\dose.txt' dlm='09'x dsd  firstobs=2;

input id $ 3. +1 dosedate date9.;

format dosedate date9.;

I got right output.This is output

Obs id dosedate

1 001 01JAN2003

2 001 02JAN2003

3 002 15MAR2003

4 002 01MAR2003

5 003 01APR2003

6 004 19MAR2003

But i see error in log file

NOTE: LOST CARD.

id=  dosedate=. _ERROR_=1 _N_=7

NOTE: 8 records were read from the infile 'C:\Users\Contacts\Desktop\dose.txt'.

      The minimum record length was 0.

      The maximum record length was 13.

NOTE: SAS went to a new line when INPUT statement reached past the end of a line.

NOTE: The data set WORK.DOSE has 6 observations and 2 variables.

NOTE: DATA statement used (Total process time):

      real time           0.04 seconds

      cpu time            0.01 seconds

There are only six records in Rawdata. But sas reading 8 records .

I need some help to understand this logfile.

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Try adding TRUNCOVER option to the INFILE statement to prevent SAS from trying to go to the next line if you read past the end of the line.

You do not need the +1 in the INPUT statement. If your data really has a tab ('09'x) between the id and the date then SAS will automatically start reading the value for the date after the tab.

View solution in original post

4 REPLIES 4
Tom
Super User Tom
Super User

Try adding TRUNCOVER option to the INFILE statement to prevent SAS from trying to go to the next line if you read past the end of the line.

You do not need the +1 in the INPUT statement. If your data really has a tab ('09'x) between the id and the date then SAS will automatically start reading the value for the date after the tab.

epr
Calcite | Level 5 epr
Calcite | Level 5

Now idon't see any error , dlm is tab but with out +1 i am getting this output

Obs id dosedate

1   001   .

2   002   .

3   002   .

4   002   .

5   003   .

6   004   .

Tom
Super User Tom
Super User

Most likely you have a space after the tab and before the date value.

Try using : modifier in front of the date format.  I worry that if your data is inconsistent about whether the extra character is there you might skip over the first actual digit of the date value using the +1 cursor movement command.  See example below using | in place of tabs.

data test;

  infile cards dlm='|' truncover ;

  input id 3. date :date9. ;

  format date date9.;

  put (id date) (=);

cards;

001|11jan2012

002| 11jan2012

003 21jan2012

run;

data_null__
Jade | Level 19

You need colon or informat statement

input id :$3. dosedate :date9.;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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