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

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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

3 REPLIES 3
Tom
Super User Tom
Super User

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.

Astounding
PROC Star

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.

AndrewOS
Fluorite | Level 6

Hi Tom

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

Thank you

Andrew

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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