BookmarkSubscribeRSS Feed
Prasad-S
Calcite | Level 5

data date;
input Patent_ID Age Date_of_admission;
informat Date_of_admission ddmmyy10.;
format Date_of_admission ddmmyy10.;
cards;
100 56 02/03/1985
200 65 02.03.1986
300 76 02-05-1987
400 82 02.04.1988
;
run;

proc print data=date;
run;

7 REPLIES 7
PaigeMiller
Diamond | Level 26

I don't see anything wrong with this code. It runs correctly for me.

 

Please go back and change the subject line to be a meaningful subject for your post. "Please correct the code" could apply to 95% of the posts here.

--
Paige Miller
Prasad-S
Calcite | Level 5

hi, Thanks for quick reply. But the output and result are not showing correct result. I could see only two observations i.e first and last one.

PaigeMiller
Diamond | Level 26

@Prasad-S wrote:

hi, Thanks for quick reply. But the output and result are not showing correct result. I could see only two observations i.e first and last one.


I run your code unchanged. I see four records when I do the PROC PRINT. Please show us the output you are seeing. Please fix the subject line in the original post.

--
Paige Miller
Prasad-S
Calcite | Level 5

Capture.PNG

 

 
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
68
69 data date;
70 input Patent_ID Age Date_of_admission;
71 informat Date_of_admission ddmmyy10.;
72 format Date_of_admission ddmmyyb10.;
73 cards;
 
NOTE: Invalid data for Patent_ID in line 75 1-6.
NOTE: Invalid data for Age in line 75 8-17.
NOTE: Invalid data for Date_of_admission in line 76 1-3.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
76 300 76 02-05-1987
NOTE: Invalid data errors for file CARDS occurred outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.
Patent_ID=. Age=. Date_of_admission=. _ERROR_=1 _N_=2
NOTE: SAS went to a new line when INPUT statement reached past the end of a line.
NOTE: The data set WORK.DATE has 3 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 666.53k
OS Memory 21156.00k
Timestamp 01/09/2023 03:27:50 PM
Step Count 31 Switch Count 2
Page Faults 0
Page Reclaims 135
Page Swaps 0
Voluntary Context Switches 10
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 264
 
 
78 ;
79 run;
80
81 proc print data=date;
82 run;
 
NOTE: There were 3 observations read from the data set WORK.DATE.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.01 seconds
user cpu time 0.01 seconds
system cpu time 0.00 seconds
memory 1146.21k
OS Memory 21156.00k
Timestamp 01/09/2023 03:27:50 PM
Step Count 32 Switch Count 0
Page Faults 0
Page Reclaims 80
Page Swaps 0
Voluntary Context Switches 0
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 8
 
 
PaigeMiller
Diamond | Level 26

Please copy the log from the SAS log window (just for the entire DATA step, we don't need the rest) and paste it into the window that appears when you click on the </> icon.

Insert Log Icon in SAS Communities.png

 

--
Paige Miller
ballardw
Super User

If you read this part of your log:

NOTE: Invalid data for Patent_ID in line 75 1-6.
NOTE: Invalid data for Age in line 75 8-17.
NOTE: Invalid data for Date_of_admission in line 76 1-3.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
76 300 76 02-05-1987
NOTE: Invalid data errors for file CARDS occurred outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.
Patent_ID=. Age=. Date_of_admission=. _ERROR_=1 _N_=2

You see that the first three lines tell you that a Date_of_admission was read from line 76 when the other two variables were read from line 75. Combine that with the "occurred outside the printed range" one starts to suspect that there are non-printable characters in you code that are not there after pasting into this forum.The indication of reading across lines means that something is interpreted as an end of line and or carriage return depending on your operating system and version of SAS.

The main message windows on this forum reformat pasted text. So the reformatting may have removed or combined your non-printable characters resulting in code that when we copy it will execute.

If you copied any or all of your datalines from another program that is a very likely source of non-printable characters and you may need to actually type the example data, or start deleting/entering spaces between any problem values.

 


@Prasad-S wrote:

Capture.PNG

 

 
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
68
69 data date;
70 input Patent_ID Age Date_of_admission;
71 informat Date_of_admission ddmmyy10.;
72 format Date_of_admission ddmmyyb10.;
73 cards;
 
NOTE: Invalid data for Patent_ID in line 75 1-6.
NOTE: Invalid data for Age in line 75 8-17.
NOTE: Invalid data for Date_of_admission in line 76 1-3.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
76 300 76 02-05-1987
NOTE: Invalid data errors for file CARDS occurred outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.
Patent_ID=. Age=. Date_of_admission=. _ERROR_=1 _N_=2
NOTE: SAS went to a new line when INPUT statement reached past the end of a line.
NOTE: The data set WORK.DATE has 3 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 666.53k
OS Memory 21156.00k
Timestamp 01/09/2023 03:27:50 PM
Step Count 31 Switch Count 2
Page Faults 0
Page Reclaims 135
Page Swaps 0
Voluntary Context Switches 10
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 264
 
 
78 ;
79 run;
80
81 proc print data=date;
82 run;
 
NOTE: There were 3 observations read from the data set WORK.DATE.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.01 seconds
user cpu time 0.01 seconds
system cpu time 0.00 seconds
memory 1146.21k
OS Memory 21156.00k
Timestamp 01/09/2023 03:27:50 PM
Step Count 32 Switch Count 0
Page Faults 0
Page Reclaims 80
Page Swaps 0
Voluntary Context Switches 0
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 8
 
 

 

Tom
Super User Tom
Super User

Thanks for the log, but the problem is on the line of data BEFORE the one that is being listed.  Basically the issue seems to be that it did not find a value of the date on the line before so it is hunting for one on the line it is showing.

 

If the problem is just that one of the lines is missing a date value you might only need to add an INFILE statement so you can use the TRUNCOVER option to prevent INPUT from going to the next line.

data date;
  infile cards truncover;
  input Patent_ID Age Date_of_admission;
  informat Date_of_admission ddmmyy10.;
  format Date_of_admission ddmmyyb10.;
cards;

Or you can just add a single period on the data lines to indicate when one of the three fields is missing.

See the third line of data in this example:

data date;
  input Patent_ID Age Date_of_admission;
  informat Date_of_admission ddmmyy10.;
  format Date_of_admission ddmmyy10.;
cards;
100 56 02/03/1985
200 65 02.03.1986
300 76 .
400 82 02.04.1988
;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 7 replies
  • 569 views
  • 1 like
  • 4 in conversation