DATA Step, Macro, Functions and more

Invalid Data for the line : Getting error in SAS - UNIX but not in SAS 9.3 or 9.4 SAS log

Reply
New Contributor
Posts: 4

Invalid Data for the line : Getting error in SAS - UNIX but not in SAS 9.3 or 9.4 SAS log

data test;
informat brthdtc colldate mmddyy10.;
 input brthdtc colldate;
format brthdtc colldate date9.;
 Key=_n_;

 cards;

4-13-1988 4-13-2012
7-13-1986 4-13-2012
6-13-1973 4-13-2012
5-13-1995 4-13-2012;

run;

 

 im seeing below line in the unix terminal at log file, but im not seeing this error in programming editor at 9.3 or 9.4. And the output is coming as expected per my requirement. what is this error and how can we remove it. Line a

 

NOTE: Invalid data for COLLDATE in line 15 11-20.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
^L2 The SAS System 03:58 Thursday, May 12, 2016

RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0

15 CHAR 4-13-1988 4-13-2012.
ZONE 32332333323233233330222222222222222222222222222222222222222222222222222222222222
NUMR 4D13D198804D13D2012D000000000000000000000000000000000000000000000000000000000000

Super User
Posts: 6,936

Re: Invalid Data for the line : Getting error in SAS - UNIX but not in SAS 9.3 or 9.4 SAS log

The semicolon that ends the cards; block must be on it's own line. Adding it to a line makes it part of the data for that line.

So your code should be like this:

data test;
informat brthdtc colldate mmddyy10.;
format brthdtc colldate date9.;
input brthdtc colldate;
Key = _n_;
cards;
4-13-1988 4-13-2012
7-13-1986 4-13-2012
6-13-1973 4-13-2012
5-13-1995 4-13-2012
;
run;

Log:

16         data test;
17         informat brthdtc colldate mmddyy10.;
18         format brthdtc colldate date9.;
19         input brthdtc colldate;
20         Key = _n_;
21         cards;

NOTE: The data set WORK.TEST has 4 observations and 3 variables.
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.00 seconds
      
26         ;

27         run;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
New Contributor
Posts: 4

Re: Invalid Data for the line : Getting error in SAS - UNIX but not in SAS 9.3 or 9.4 SAS log

Hey, Thank you for your fast reply,

 

Problem has not resolved, even i have tried like that, but issue has not solved.

 

Note  im seeing is "Invalid Data for the line :   below is the message im seeing in log file which is generated in UNIX at location

 

  data test;
9 informat brthdtc colldate mmddyy10.;
10 format brthdtc colldate date9.;
11 input brthdtc colldate;
12 Key = _n_;
13 cards;

NOTE: Invalid data for COLLDATE in line 14 11-20.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
^L2 The SAS System 05:20 Thursday, May 12, 2016

RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0

14 CHAR 4-13-1988 4-13-2012.
ZONE 32332333323233233330222222222222222222222222222222222222222222222222222222222222
NUMR 4D13D198804D13D2012D000000000000000000000000000000000000000000000000000000000000
BRTHDTC=13APR1988 COLLDATE=. KEY=1 _ERROR_=1 _N_=1
NOTE: Invalid data for COLLDATE in line 15 11-20.

15 CHAR 7-13-1986 4-13-2012.
ZONE 32332333323233233330222222222222222222222222222222222222222222222222222222222222
NUMR 7D13D198604D13D2012D000000000000000000000000000000000000000000000000000000000000
BRTHDTC=13JUL1986 COLLDATE=. KEY=2 _ERROR_=1 _N_=2
NOTE: Invalid data for COLLDATE in line 16 11-20.

 

 

 

 

Super User
Posts: 6,936

Re: Invalid Data for the line : Getting error in SAS - UNIX but not in SAS 9.3 or 9.4 SAS log

Look at this line from the log:

14 CHAR 4-13-1988 4-13-2012.

The dot at the end should not be there. I get a similar log line if I add a dot to a line in my cards; block, which is as expected.

Maybe you get additional characters when you transfer your program to UNIX (because the Windows CRLF is not converted to the correct UNIX LF).

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Trusted Advisor
Posts: 1,115

Re: Invalid Data for the line : Getting error in SAS - UNIX but not in SAS 9.3 or 9.4 SAS log

[ Edited ]

The dot represents the non-printable character '0D'x (see ZONE and NUMR lines), i.e. carriage return, CR. So, it's indeed the difference between Windows and Unix regarding the end-of-line character: Unix interprets the CR as part of the data and only the LF ('0A'x) as end-of-line character.

 

If the data were read from an external file, the TERMSTR=CRLF option of the INFILE statement would solve the issue, but this option is not available for INFILE CARDS. So, you may want to try the PARMCARDS statement:

filename ft15f001 temp;

data test;
infile ft15f001 termstr=CRLF;
informat brthdtc colldate mmddyy10.;
input brthdtc colldate;
format brthdtc colldate date9.;
Key=_n_;
parmcards;
4-13-1988 4-13-2012
7-13-1986 4-13-2012
6-13-1973 4-13-2012
5-13-1995 4-13-2012
;

This works with my Windows SAS. I don't have Unix SAS.

 

EDIT: Or, even simpler: Add '0D'x to the list of delimiters. Just insert this line into your code:

infile cards dlm='200D'x;
Super User
Posts: 6,936

Re: Invalid Data for the line : Getting error in SAS - UNIX but not in SAS 9.3 or 9.4 SAS log

If it is actually the CRLF problem (if you open the program file from the UNIX commandline with vi, you see ^M at the end of each line), then I recommend to save the program to the UNIX server through the Files tree in the Enterprise Guide server list, as the conversion is done automatically.

Otherwise, when copying the file via FTP, make sure that the transfer mode is set to "text".

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Ask a Question
Discussion stats
  • 5 replies
  • 302 views
  • 0 likes
  • 3 in conversation