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

Error I am receiving.. all of my data is listed in one column instead of three. And Im only getting 10 observations there should be at least 30-40.

 

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73 data hwbiostat6;
74 infile "/folders/myfolders/hwbiostat6/ch12q06.txt" dlm='09'x firstobs=2;
75 input SEX $ Y X;
76 if sex="M" then Zsex=1;
77 else Zsex=0;
78 Xsex= X*Zsex;
79 datalines;
 
NOTE: The infile "/folders/myfolders/hwbiostat6/ch12q06.txt" is:
Filename=/folders/myfolders/hwbiostat6/ch12q06.txt,
Owner Name=root,Group Name=vboxsf,
Access Permission=-rwxrwx---,
Last Modified=08Apr2021:00:24:53,
File Size (bytes)=534
 
NOTE: Invalid data for Y in line 3 1-14.
NOTE: Invalid data for X in line 4 1-14.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
4 'M',21.6,0.301 14
NOTE: Invalid data errors for file '"/folders/myfolders/hwbiostat6/ch12q06.txt"' occurred outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.
SEX='M',17.1 Y=. X=. Zsex=0 Xsex=. _ERROR_=1 _N_=1
NOTE: Invalid data for Y in line 6 1-14.
NOTE: Invalid data for X in line 7 1-14.
7 'M',23.8,0.602 14
NOTE: Invalid data errors for file '"/folders/myfolders/hwbiostat6/ch12q06.txt"' occurred outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.
SEX='M',24.5 Y=. X=. Zsex=0 Xsex=. _ERROR_=1 _N_=2
NOTE: Invalid data for Y in line 9 1-12.
NOTE: Invalid data for X in line 10 1-14.
10 'M',29.4,0.903 14
NOTE: Invalid data errors for file '"/folders/myfolders/hwbiostat6/ch12q06.txt"' occurred outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.
SEX='M',27.7 Y=. X=. Zsex=0 Xsex=. _ERROR_=1 _N_=3
NOTE: Invalid data for Y in line 12 1-14.
NOTE: Invalid data for X in line 13 1-14.
13 'M',34.2,1.204 14
NOTE: Invalid data errors for file '"/folders/myfolders/hwbiostat6/ch12q06.txt"' occurred outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.
SEX='M',30.1 Y=. X=. Zsex=0 Xsex=. _ERROR_=1 _N_=4
NOTE: Invalid data for Y in line 15 1-14.
NOTE: Invalid data for X in line 16 1-14.
16 'M',31.8,1.505 14
NOTE: Invalid data errors for file '"/folders/myfolders/hwbiostat6/ch12q06.txt"' occurred outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.
SEX='M',37.3 Y=. X=. Zsex=0 Xsex=. _ERROR_=1 _N_=5
NOTE: Invalid data for Y in line 18 1-14.
NOTE: Invalid data for X in line 19 1-14.
19 'F',22.1,0.301 14
NOTE: Invalid data errors for file '"/folders/myfolders/hwbiostat6/ch12q06.txt"' occurred outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.
SEX='M',40.2 Y=. X=. Zsex=0 Xsex=. _ERROR_=1 _N_=6
NOTE: Invalid data for Y in line 21 1-14.
NOTE: Invalid data for X in line 22 1-14.
22 'F',26.9,0.602 14
NOTE: Invalid data errors for file '"/folders/myfolders/hwbiostat6/ch12q06.txt"' occurred outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.
SEX='F',15.3 Y=. X=. Zsex=0 Xsex=. _ERROR_=1 _N_=7
NOTE: Invalid data for Y in line 24 1-14.
NOTE: Invalid data for X in line 25 1-14.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
25 'F',27.1,0.903 14
NOTE: Invalid data errors for file '"/folders/myfolders/hwbiostat6/ch12q06.txt"' occurred outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.
SEX='F',20.2 Y=. X=. Zsex=0 Xsex=. _ERROR_=1 _N_=8
NOTE: Invalid data for Y in line 27 1-14.
NOTE: Invalid data for X in line 28 1-14.
28 'F',30.3,1.204 14
NOTE: Invalid data errors for file '"/folders/myfolders/hwbiostat6/ch12q06.txt"' occurred outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.
SEX='F',30.1 Y=. X=. Zsex=0 Xsex=. _ERROR_=1 _N_=9
NOTE: Invalid data for Y in line 30 1-14.
NOTE: Invalid data for X in line 31 1-14.
31 'F',32.6,1.505 14
NOTE: Invalid data errors for file '"/folders/myfolders/hwbiostat6/ch12q06.txt"' occurred outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.
SEX='F',33,1 Y=. X=. Zsex=0 Xsex=. _ERROR_=1 _N_=10
NOTE: Invalid data for Y in line 33 1-14.
NOTE: LOST CARD.
NOTE: Invalid data errors for file '"/folders/myfolders/hwbiostat6/ch12q06.txt"' occurred outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.
SEX='F',36.1 Y=. X=. Zsex=. Xsex=. _ERROR_=1 _N_=11
NOTE: 32 records were read from the infile "/folders/myfolders/hwbiostat6/ch12q06.txt".
The minimum record length was 12.
The maximum record length was 14.
NOTE: SAS went to a new line when INPUT statement reached past the end of a line.
NOTE: Missing values were generated as a result of performing an operation on missing values.
Each place is given by: (Number of times) at (Line):(Column).
10 at 78:9
NOTE: The data set WORK.HWBIOSTAT6 has 10 observations and 5 variables.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
cpu time 0.00 seconds
 
 
112 ;
113 run;
114
115 proc print data=hwbiostat6;
116 run;
 
NOTE: There were 10 observations read from the data set WORK.HWBIOSTAT6.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.14 seconds
cpu time 0.13 seconds
 
 
117
118
119
120
121
122
123
124
125 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 

Code I used

 

data hwbiostat6;
infile "/folders/myfolders/hwbiostat6/ch12q06.txt" dlm='09'x firstobs=2;
input SEX $ Y X;
if sex="M" then Zsex=1;
else Zsex=0;
Xsex= X*Zsex;
datalines;
M 17.1 0.301
M 14.3 0.301
M 21.6 0.301
M 24.5 0.602
M 20.6 0.602
M 23.8 0.602
M 27.7 0.903
M 31 0.903
M 29.4 0.903
M 30.1 1.204
M 28.6 1.204
M 34.2 1.204
M 37.3 1.204
M 33.3 1.505
M 31.8 1.505
M 40.2 1.505
F 18.5 0.301
F 22.1 0.301
F 15.3 0.301
F 23.6 0.602
F 26.9 0.602
F 20.2 0.602
F 24.3 0.903
F 27.1 0.903
F 30.1 0.903
F 28.1 0.903
F 30.3 1.204
F 33 1.204
F 35.8 1.204
F 32.6 1.505
F 36.1 1.505
F 30.5 1.505
;
run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
japelin
Rhodochrosite | Level 12

Please attach ch12q06.txt.
Also, why are you using infile statements and datalines ry?

View solution in original post

5 REPLIES 5
japelin
Rhodochrosite | Level 12

Please attach ch12q06.txt.
Also, why are you using infile statements and datalines ry?

sarahbaker012
Calcite | Level 5

Im using SAS university. I think I may have figured it out using dsd instead of dlm. Let me know what you think.

japelin
Rhodochrosite | Level 12

Yes, I think you can use the dsd option instead of dlm since it is a csv file.

sarahbaker012
Calcite | Level 5

It worked, thank you!

ballardw
Super User

It is probably time for you to learn that opening files that are CSV with a spreadsheet can change things.

Your original file was comma separated and you wrote a data step to read a TAB delimited file, almost certainly because you copied cells from a spreadsheet.

Dlm=',' with the file likely fixes lots of issues.

We can tell such things as the file was comma delimited by reading the log:

RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
4 'M',21.6,0.301 14

The bit between the "4" and the "14" is the actual content of the file read.

You want to copy from the log and paste copied text into a text box opened on the forum with the </> icon to preserver the text formatting that SAS has in the log. I bet that if you look in your log that the 'M' for that line started on column 4 of the file with the first quote under the - character before the first + sign. The + occurs as position multiples of 5 characters, the 1, 2, 3 etc indicate column 10, 20, and 30 .

 

The main message windows on this forum reformat text, generally removing white space, so fixed column information from the line ruler above gets corrupted.

 

 

SAS Innovate 2025: Register Today!

 

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 5 replies
  • 830 views
  • 0 likes
  • 3 in conversation