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.
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.
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.
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.
Hi Tom
I was copying the variables names from an layout file and there were indeed duplicates.
Thank you
Andrew
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.