SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

Input file has less columns than what is defined in input step of sas macro

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 82
Accepted Solution

Input file has less columns than what is defined in input step of sas macro

If I am  reading data from a comma separated text file and in my input step i declare 5 columns and if in the input file there are only 3 comma separated values, will I get exception?

Or will the resultset be created with 5 columns with 3 columns populated and the other columns as null?


Accepted Solutions
Solution
‎07-04-2014 03:16 PM
Super User
Super User
Posts: 6,502

Re: Input file has less columns than what is defined in input step of sas macro

It depends on the settings on your INFILE statement. If you use the TRUNCOVER option then the extra variables will be all missing.  Similarly if there is extra information on the line it will be ignored.

Try this little example.

data x;

infile cards dsd truncover ;

input v1-v5;

cards;

1

1,2

1,2,3

1,2,3,4

1,2,3,4,5

1,2,3,4,5,6

run;

View solution in original post


All Replies
Solution
‎07-04-2014 03:16 PM
Super User
Super User
Posts: 6,502

Re: Input file has less columns than what is defined in input step of sas macro

It depends on the settings on your INFILE statement. If you use the TRUNCOVER option then the extra variables will be all missing.  Similarly if there is extra information on the line it will be ignored.

Try this little example.

data x;

infile cards dsd truncover ;

input v1-v5;

cards;

1

1,2

1,2,3

1,2,3,4

1,2,3,4,5

1,2,3,4,5,6

run;

Trusted Advisor
Posts: 1,204

Re: Input file has less columns than what is defined in input step of sas macro

You will get 5 columns with 3 columns populated remaining as null.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 244 views
  • 3 likes
  • 3 in conversation