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

The following is my code:

/* Enter Data */
data leaf;
	input Delay Angle @@;
	cards;
	30 140  30 138  30 140  30 138	30 142
	45 140  45 150  45 120  45 128	45 130
	60 118  60 130  60 128  60 118	60 118
;
run;

/* Comparing All Delays */
proc glm data=leaf plots=diagnostics;
	class Delay;
	model Angle = Delay;
	means Delay / HOVtest=Levene;
	title "Comparison of All Delays";
run;

When I run the code, I receive the following:

FoxCode_0-1633205994161.png

My issue is that the Delay variable should only have 3 levels with values of 30 45 60 but as you can see, it is reading in more levels than it should. To me, the data looks perfectly fine and I have no idea why it's not reading correctly. Any and all help is greatly appreciated!

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

DO NOT insert TAB characters into data lines.  

If you replace the TAB characters with PIPE characters you can see your problem more clearly.

data leaf;
|input Delay Angle @@;
|cards;
|30 140  30 138  30 140  30 138|30 142
|45 140  45 150  45 120  45 128|45 130
|60 118  60 130  60 128  60 118|60 118
;
546   data leaf;
547     input Delay Angle @@;
548   cards;

NOTE: Invalid data for Delay in line 549 1-3.
RULE:       ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
549         |30 140  30 138  30 140  30 138|30 142
Delay=0 Angle=140 _ERROR_=1 _N_=1
NOTE: Invalid data for Angle in line 549 29-34.
NOTE: Invalid data errors for file CARDS occurred outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.
Delay=30 Angle=0 _ERROR_=1 _N_=4
NOTE: Invalid data for Angle in line 550 1-3.
550         |45 140  45 150  45 120  45 128|45 130
Delay=142 Angle=0 _ERROR_=1 _N_=5
NOTE: Invalid data for Delay in line 550 29-34.
NOTE: Invalid data errors for file CARDS occurred outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.
Delay=0 Angle=130 _ERROR_=1 _N_=9
NOTE: Invalid data for Delay in line 551 1-3.
551         |60 118  60 130  60 128  60 118|60 118
Delay=0 Angle=118 _ERROR_=1 _N_=10
NOTE: Invalid data for Angle in line 551 29-34.
NOTE: Invalid data errors for file CARDS occurred outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.
Delay=60 Angle=0 _ERROR_=1 _N_=13
NOTE: LOST CARD.
552         ;
Delay=118 Angle=0 _ERROR_=1 _N_=14
NOTE: SAS went to a new line when INPUT statement reached past the end of a line.
NOTE: The data set WORK.LEAF has 13 observations and 2 variables.

Also DO NOT indent the lines of data.  To remind yourself do not intend the CARDS/DATALINES statement either.  Then you will be less like to accidently get the tabs moved from the beginning of the line into the middle.

data leaf;
  input Delay Angle @@;
cards;
30 140  30 138  30 140  30 138 30 142
45 140  45 150  45 120  45 128 45 130
60 118  60 130  60 128  60 118 60 118
;

 

In general do not insert TAB characters into SAS program files at all. You can tell your SAS editor to insert the number of spaces you want to use when you hit the TAB key without actually sticking the '09'x character into the file to cause these kinds of trouble.

View solution in original post

9 REPLIES 9
Tom
Super User Tom
Super User

Please show the lines from the SAS log for the DATA step. It should indicate how many observations written and how many lines read.

FoxCode
Fluorite | Level 6

I removed all Tab characters from the data input chunk. Here is the log that I receive:

FoxCode_0-1633210063967.png

 

FoxCode
Fluorite | Level 6

Additionally, here is the Output Data tab:

FoxCode_0-1633210169318.png

 

Tom
Super User Tom
Super User

You didn't remove/replace the tabs in column 31.

FoxCode
Fluorite | Level 6
Tom, I apologize but I am very confused. I don't have a single Tab character in my entire file. I also don't have a column 31, let alone a line 31 (this is a very short code and I'm just trying to get the data to read correctly). I'm not very experienced with interpreting the SAS Log/Output Data, so I'm lost on what I'm doing wrong here.
Tom
Super User Tom
Super User

The photograph of the SAS log you posted is clearly showing that the lines of data have the hex character 09 in the 31st column.

image.png

FoxCode
Fluorite | Level 6
Tom, I deleted all of the data and re-typed it in, and it somehow fixed it. When I originally inputted the data, I did have Tab characters but I replaced them all with spaces instead. For some reason, it was still reading a Tab character even though it didn't exist. Thank you so much for your help!
Tom
Super User Tom
Super User

How are you submitting SAS code?  Are you using Display Manager?  SAS/Studio? Something else?

 

In Display Manager you can tell it to replace tabs with spaces.

image.png

Same thing for SAS/Studio

image.png

Tom
Super User Tom
Super User

DO NOT insert TAB characters into data lines.  

If you replace the TAB characters with PIPE characters you can see your problem more clearly.

data leaf;
|input Delay Angle @@;
|cards;
|30 140  30 138  30 140  30 138|30 142
|45 140  45 150  45 120  45 128|45 130
|60 118  60 130  60 128  60 118|60 118
;
546   data leaf;
547     input Delay Angle @@;
548   cards;

NOTE: Invalid data for Delay in line 549 1-3.
RULE:       ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
549         |30 140  30 138  30 140  30 138|30 142
Delay=0 Angle=140 _ERROR_=1 _N_=1
NOTE: Invalid data for Angle in line 549 29-34.
NOTE: Invalid data errors for file CARDS occurred outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.
Delay=30 Angle=0 _ERROR_=1 _N_=4
NOTE: Invalid data for Angle in line 550 1-3.
550         |45 140  45 150  45 120  45 128|45 130
Delay=142 Angle=0 _ERROR_=1 _N_=5
NOTE: Invalid data for Delay in line 550 29-34.
NOTE: Invalid data errors for file CARDS occurred outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.
Delay=0 Angle=130 _ERROR_=1 _N_=9
NOTE: Invalid data for Delay in line 551 1-3.
551         |60 118  60 130  60 128  60 118|60 118
Delay=0 Angle=118 _ERROR_=1 _N_=10
NOTE: Invalid data for Angle in line 551 29-34.
NOTE: Invalid data errors for file CARDS occurred outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.
Delay=60 Angle=0 _ERROR_=1 _N_=13
NOTE: LOST CARD.
552         ;
Delay=118 Angle=0 _ERROR_=1 _N_=14
NOTE: SAS went to a new line when INPUT statement reached past the end of a line.
NOTE: The data set WORK.LEAF has 13 observations and 2 variables.

Also DO NOT indent the lines of data.  To remind yourself do not intend the CARDS/DATALINES statement either.  Then you will be less like to accidently get the tabs moved from the beginning of the line into the middle.

data leaf;
  input Delay Angle @@;
cards;
30 140  30 138  30 140  30 138 30 142
45 140  45 150  45 120  45 128 45 130
60 118  60 130  60 128  60 118 60 118
;

 

In general do not insert TAB characters into SAS program files at all. You can tell your SAS editor to insert the number of spaces you want to use when you hit the TAB key without actually sticking the '09'x character into the file to cause these kinds of trouble.

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!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 9 replies
  • 686 views
  • 3 likes
  • 2 in conversation