DATA Step, Macro, Functions and more

Variables getting droped from external file

Accepted Solution Solved
Reply
Contributor
Posts: 20
Accepted Solution

Variables getting droped from external file

Hi

 

I am reading an ebcdic flat file into sas.

It is creating the data set but it is dropping a number of variables off the end of each record. The external file has 303 columns/variables, my input statement has 303 columns/variables defined but the resulting dataset only contains 276 columns/variables.

The data the is in the data set looks correct but I cannot understand why the variables are not getting picked up.

The input statement is

DATA WORK.file;

INFILE 'filename' recfm=f lrecl=858;

input

    var1             s370fpd5.

    var2            $ebcdic

    etc

    etc.

The length is correct and the last variable to be read stops at position 824.

Any help would be greatly appriciated.


Accepted Solutions
Solution
‎10-15-2012 10:33 AM
Super User
Super User
Posts: 7,039

Re: Variables getting droped from external file

Not sure what you mean by "dropping" variables.  If you mean the values are all missing then make sure the lines are not truncated.

A simple way to look at the file is to use the LIST statement .  This will show you the HEX codes for lines that are not all normal printable ASCII characters.  I normally just list a few lines so that I can see the patterns.

data _null_;

  INFILE 'filename' recfm=f lrecl=858;

  input;

  list;

  if _n_ > 10 then stop;

run;

If instead you mean the variables do not end up in the output dataset then check that your INPUT statement is not reusing the same variable names.

View solution in original post


All Replies
Solution
‎10-15-2012 10:33 AM
Super User
Super User
Posts: 7,039

Re: Variables getting droped from external file

Not sure what you mean by "dropping" variables.  If you mean the values are all missing then make sure the lines are not truncated.

A simple way to look at the file is to use the LIST statement .  This will show you the HEX codes for lines that are not all normal printable ASCII characters.  I normally just list a few lines so that I can see the patterns.

data _null_;

  INFILE 'filename' recfm=f lrecl=858;

  input;

  list;

  if _n_ > 10 then stop;

run;

If instead you mean the variables do not end up in the output dataset then check that your INPUT statement is not reusing the same variable names.

Super User
Posts: 5,500

Re: Variables getting droped from external file

All valid points!  Also ...

Are the variables you do have being assigned the proper value?  Check a few toward the end of the INPUT statement.  (Tom's suggestion about the LIST statement may help in that effort.)  While you may have taken liberties when posting your sample program, the sample you posted would define EBCDIC as another variable (one which you may not be mentioned in a subsequent KEEP statement).  Another liberty ... have you used other options such as MISSOVER or TRUNCOVER?  They can hide problems with the INPUT statement.  If you feel comfortable doing this, posting your log may help diagnose the problem.

Good luck.

Contributor
Posts: 20

Re: Variables getting droped from external file

Hi Tom

I was copying the variables names from an layout file and there were indeed duplicates.

Thank you

Andrew

🔒 This topic is solved and locked.

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

Discussion stats
  • 3 replies
  • 196 views
  • 0 likes
  • 3 in conversation