Regular Learner
Posts: 1

num Y x1 x2 x3 x4
1 11 1 0 0 0
2 17 1 0 0 0
3 16 1 0 0 0
4 14 1 0 0 0
5 15 1 0 0 0
6 12 2 1 0 0

I read the above-named dataset (also attached for proper viewing) saved as ak.txt into SAS University edition and SAS did not read the dataset correctly.

This is the code I used:
72
73 data project;
74 infile "/folders/myfolders/ak.txt";
75 input num\$ y\$ x1\$ x2\$ x3\$ x4\$ x5\$ x6\$;
76 run;

This is the output I obtained:

1 Y x1 x2 x3 x4 1 11 1
2 2 17 1 0 0 0 3 16
3 4 14 1 0 0 0 5 15

Any ideas to solve this problem for SAS to give the right output,please?

This is the log:

NOTE: LOST CARD.
num=6 y=12 x1=2 x2=1 x3=0 x4=0 x5= x6= _ERROR_=1 _N_=4
NOTE: 7 records were read from the infile "/folders/myfolders/ak.txt".
The minimum record length was 22.
The maximum record length was 22.
NOTE: SAS went to a new line when INPUT statement reached past the end of a line.
NOTE: The data set WORK.PROJECT has 3 observations and 8 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

Super User
Posts: 23,778

num Y x1 x2 x3 x4

input num\$ y\$ x1\$ x2\$ x3\$ x4\$ x5\$ x6\$;

You're showing different number of variables, do you only have 4 or 6? It looks like it doesn't align so that's possibly your issue. The note indicates this as well:

NOTE: SAS went to a new line when INPUT statement reached past the end of a line.

ak2011 wrote:

num Y x1 x2 x3 x4
1 11 1 0 0 0
2 17 1 0 0 0
3 16 1 0 0 0
4 14 1 0 0 0
5 15 1 0 0 0
6 12 2 1 0 0

I read the above-named dataset (also attached for proper viewing) saved as ak.txt into SAS University edition and SAS did not read the dataset correctly.

This is the code I used:
72
73 data project;
74 infile "/folders/myfolders/ak.txt";
75 input num\$ y\$ x1\$ x2\$ x3\$ x4\$ x5\$ x6\$;
76 run;

This is the output I obtained:

1 Y x1 x2 x3 x4 1 11 1
2 2 17 1 0 0 0 3 16
3 4 14 1 0 0 0 5 15

Any ideas to solve this problem for SAS to give the right output,please?

This is the log:

NOTE: LOST CARD.
num=6 y=12 x1=2 x2=1 x3=0 x4=0 x5= x6= _ERROR_=1 _N_=4
NOTE: 7 records were read from the infile "/folders/myfolders/ak.txt".
The minimum record length was 22.
The maximum record length was 22.
NOTE: SAS went to a new line when INPUT statement reached past the end of a line.
NOTE: The data set WORK.PROJECT has 3 observations and 8 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

Highlighted
PROC Star
Posts: 514

use FIRSTOBS=2 in your infile statement

Super User
Posts: 23,778

And one last thing, you're currently reading them all as character (with the \$ sign), you may want them to be numeric if you want to summarize or add them.
Discussion stats
• 3 replies
• 209 views
• 2 likes
• 3 in conversation