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:
I am unsure why the numbers do not show up, and only 7 rows?
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 ;
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.
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 ;
my log says :
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.
Yeah, there was a double space and thus it wouldn't register it. Thank you!
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:
I am unsure why the numbers do not show up, and only 7 rows?
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.
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
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.
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:
I am unsure why the numbers do not show up, and only 7 rows?
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.