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

I wrote the following code: 

 

DATA test1;
input puma median;
datalines;
11 61000.00
12 68000.00
20 68400.00
30 88000.00
41 77400.00
42 84040.00
50 103000.00
60 65400.00
70 47800.00
80 75000.00
90 92000.00
101 80000.00
102 99000.00
110 64400.00
120 79300.00
;

 

However, the following is the result:

 

 Screen Shot 2018-11-26 at 5.31.51 PM.pngI am unsure why the numbers do not show up, and only 7 rows? 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

That log does not match the photograph you posted before.  The log says there are 15 observations and in the photograph it looks like it is saying there are only 7 observations.   If tried to read 15 lines of data with two values per line and SAS saw the lines as having only one value because there was no space between the values then you would have gotten 7 observations with all missing values.

 

To see that try this example:

data bad ;
  input x y;
cards;
1-2
3-4
5-6
;

data good;
  input x y;
cards;
1 2
3 4
5 6
;
3337  data bad ;
3338    input x y;
3339  cards;

NOTE: Invalid data for x in line 3340 1-3.
NOTE: Invalid data for y in line 3341 1-3.
RULE:       ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
3341        3-4
NOTE: Invalid data errors for file CARDS occurred outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.
x=. y=. _ERROR_=1 _N_=1
NOTE: Invalid data for x in line 3342 1-3.
NOTE: LOST CARD.
RULE:       ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
3343        ;
NOTE: Invalid data errors for file CARDS occurred outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.
x=. y=. _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.BAD has 1 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.25 seconds
      cpu time            0.01 seconds


3343  ;
3344
3345  data good;
3346    input x y;
3347  cards;

NOTE: The data set WORK.GOOD has 3 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.08 seconds
      cpu time            0.00 seconds

3351  ;

View solution in original post

11 REPLIES 11
r_behata
Barite | Level 11

No Issues with the code.

 

 

here is the log :

 

NOTE: Compression was disabled for data set WORK.TEST1 because compression overhead would increase the size of the data set.
NOTE: The data set WORK.TEST1 has 15 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
cpu time 0.00 seconds

 

post your log.

 

 

Tom
Super User Tom
Super User

That log does not match the photograph you posted before.  The log says there are 15 observations and in the photograph it looks like it is saying there are only 7 observations.   If tried to read 15 lines of data with two values per line and SAS saw the lines as having only one value because there was no space between the values then you would have gotten 7 observations with all missing values.

 

To see that try this example:

data bad ;
  input x y;
cards;
1-2
3-4
5-6
;

data good;
  input x y;
cards;
1 2
3 4
5 6
;
3337  data bad ;
3338    input x y;
3339  cards;

NOTE: Invalid data for x in line 3340 1-3.
NOTE: Invalid data for y in line 3341 1-3.
RULE:       ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
3341        3-4
NOTE: Invalid data errors for file CARDS occurred outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.
x=. y=. _ERROR_=1 _N_=1
NOTE: Invalid data for x in line 3342 1-3.
NOTE: LOST CARD.
RULE:       ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
3343        ;
NOTE: Invalid data errors for file CARDS occurred outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.
x=. y=. _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.BAD has 1 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.25 seconds
      cpu time            0.01 seconds


3343  ;
3344
3345  data good;
3346    input x y;
3347  cards;

NOTE: The data set WORK.GOOD has 3 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.08 seconds
      cpu time            0.00 seconds

3351  ;
Reeza
Super User

@Tom I believe @r_behata is responding to the OP which is @lt1. I don't believe they are the same person. 

lt1
Fluorite | Level 6 lt1
Fluorite | Level 6

my log says :

 

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73 DATA test1;
74 input puma median;
75 datalines;
 
NOTE: Invalid data for puma in line 76 1-11.
NOTE: Invalid data for median in line 77 1-11.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
 
77 CHAR 12.68000.00
ZONE 33033333233222222222222222222222222222222222222222222222222222222222222222222222
NUMR 12968000E00000000000000000000000000000000000000000000000000000000000000000000000
NOTE: Invalid data errors for file CARDS occurred outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.
puma=. median=. _ERROR_=1 _N_=1
NOTE: Invalid data for puma in line 78 1-11.
NOTE: Invalid data for median in line 79 1-11.
 
79 CHAR 30.88000.00
ZONE 33033333233222222222222222222222222222222222222222222222222222222222222222222222
NUMR 30988000E00000000000000000000000000000000000000000000000000000000000000000000000
NOTE: Invalid data errors for file CARDS occurred outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.
puma=. median=. _ERROR_=1 _N_=2
NOTE: Invalid data for puma in line 80 1-11.
NOTE: Invalid data for median in line 81 1-11.
 
81 CHAR 42.84040.00
ZONE 33033333233222222222222222222222222222222222222222222222222222222222222222222222
NUMR 42984040E00000000000000000000000000000000000000000000000000000000000000000000000
NOTE: Invalid data errors for file CARDS occurred outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.
puma=. median=. _ERROR_=1 _N_=3
NOTE: Invalid data for puma in line 82 1-12.
NOTE: Invalid data for median in line 83 1-11.
 
83 CHAR 60.65400.00
ZONE 33033333233222222222222222222222222222222222222222222222222222222222222222222222
NUMR 60965400E00000000000000000000000000000000000000000000000000000000000000000000000
NOTE: Invalid data errors for file CARDS occurred outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.
puma=. median=. _ERROR_=1 _N_=4
NOTE: Invalid data for puma in line 84 1-11.
NOTE: Invalid data for median in line 85 1-11.
 
85 CHAR 80.75000.00
ZONE 33033333233222222222222222222222222222222222222222222222222222222222222222222222
NUMR 80975000E00000000000000000000000000000000000000000000000000000000000000000000000
NOTE: Invalid data errors for file CARDS occurred outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.
puma=. median=. _ERROR_=1 _N_=5
NOTE: Invalid data for puma in line 86 1-11.
NOTE: Invalid data for median in line 87 1-12.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
 
87 CHAR 101.80000.00
ZONE 33303333323322222222222222222222222222222222222222222222222222222222222222222222
NUMR 101980000E0000000000000000000000000000000000000000000000000000000000000000000000
NOTE: Invalid data errors for file CARDS occurred outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.
puma=. median=. _ERROR_=1 _N_=6
NOTE: Invalid data for puma in line 88 1-12.
NOTE: Invalid data for median in line 89 1-12.
 
89 CHAR 110.64400.00
ZONE 33303333323322222222222222222222222222222222222222222222222222222222222222222222
NUMR 110964400E0000000000000000000000000000000000000000000000000000000000000000000000
NOTE: Invalid data errors for file CARDS occurred outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.
puma=. median=. _ERROR_=1 _N_=7
NOTE: Invalid data for puma in line 90 1-12.
NOTE: LOST CARD.
91 ;
NOTE: Invalid data errors for file CARDS occurred outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.
puma=. median=. _ERROR_=1 _N_=8
NOTE: SAS went to a new line when INPUT statement reached past the end of a line.
NOTE: The data set WORK.TEST1 has 7 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
 
 
91 ;
92
93 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
106
 
Tom
Super User Tom
Super User

So the SAS log is telling you that your lines of text have tabs, '09'x, instead of spaces, '20'x, between the fields.

NOTE: Invalid data for puma in line 76 1-11.
NOTE: Invalid data for median in line 77 1-11.
   RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
 
 77 CHAR 12.68000.00
    ZONE 33033333233222222222222222222222222222222222222222222222222222222222222222222222
    NUMR 12968000E00000000000000000000000000000000000000000000000000000000000000000000000

If you look carefully at the SAS log you can see that is is showing that the first three characters on the line are '31'x, '32'x and '09'x.  In other words the digits 1 and 2 and a tab character.

 

It is not a good idea to use tab characters in SAS code and a really bad idea to use it in in-line data.

 

If you want to use tab as a delimiter between the values in your data then store the data in a file and use the DSD and DLM option on the INFILE statement.

lt1
Fluorite | Level 6 lt1
Fluorite | Level 6

Yeah, there was a double space and thus it wouldn't register it. Thank you!

Reeza
Super User

Works fine for me, can you post your log? Are you running in Windows or Unix?

 


@lt1 wrote:

I wrote the following code: 

 

DATA test1;
input puma median;
datalines;
11 61000.00
12 68000.00
20 68400.00
30 88000.00
41 77400.00
42 84040.00
50 103000.00
60 65400.00
70 47800.00
80 75000.00
90 92000.00
101 80000.00
102 99000.00
110 64400.00
120 79300.00
;

 

However, the following is the result:

 

 Screen Shot 2018-11-26 at 5.31.51 PM.pngI am unsure why the numbers do not show up, and only 7 rows? 


 

ballardw
Super User

Did you actually type that code into the Studio editor or perhaps copy-and-paste? If pasted the original source may have things you can't see and cause odd errors depending on the actual values. The log may show strange results but we would have to see it to be sure.

VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

something in the way you have defined the data that is not showing, while this dataline may be the one creating your issue due to the length of the value.

50 103000.00

Tom
Super User Tom
Super User

Make sure that you have an actual space character between the two values on the line. Also that there are not strange characters on the end of the line.  You might have a tab character there. Or a perhaps 'A0'x, which Windows has defined as a non-breaking space.  Or perhaps a '00'x null character.

Reeza
Super User

If it's tab delimited you would do the following instead:

 

DATA test1;
infile datalines dlm='09'x;
input puma median;
datalines;

@lt1 wrote:

I wrote the following code: 

 

DATA test1;
input puma median;
datalines;
11 61000.00
12 68000.00
20 68400.00
30 88000.00
41 77400.00
42 84040.00
50 103000.00
60 65400.00
70 47800.00
80 75000.00
90 92000.00
101 80000.00
102 99000.00
110 64400.00
120 79300.00
;

 

However, the following is the result:

 

 Screen Shot 2018-11-26 at 5.31.51 PM.pngI am unsure why the numbers do not show up, and only 7 rows? 


 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 11 replies
  • 10614 views
  • 2 likes
  • 6 in conversation