- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello All
I am learning sas now . I am practicing some small projects posted online.
This is one clinical trials project.
rawdate
Patient | Dose Date |
001 | 01Jan2003 |
001 | 02Jan2003 |
002 | 15Mar2003 |
002 | 01Mar2003 |
003 | 01Apr2003 |
004 | 19Mar2003 |
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
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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 .
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You need colon or informat statement
input id :$3. dosedate :date9.;