BookmarkSubscribeRSS Feed
ak2011
Fluorite | Level 6

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


Please note:
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

3 REPLIES 3
Reeza
Super User

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


Please note:
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


 

kiranv_
Rhodochrosite | Level 12

use FIRSTOBS=2 in your infile statement

Reeza
Super User
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.

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
  • 3 replies
  • 1065 views
  • 2 likes
  • 3 in conversation