I'm trying to import a flat file using proc iimport defining the informats and formats and input variables. But in the input file, instead of having a single line per record, two lines make a single record. this is throwing off the data alignment. As shown below:
*","01","8","","","","","","","","","","","","","AbcRgH5172675"," ","1","","A","02","","01","000","p","▒ ","UK","","
","","N","0NNNN","0000000711","","","","","","","","","","","","","","","","","","","N","","","","","",""
this is causing an issue when reading the data.there are a ttoal of 55 variables. I'm using the following procedure:
data a;
infile '/home/usr/test_file' dlm=',' dsd MISSOVER lrecl=534;
informat STREET_AD_1_TX $35.;
informat STREET_AD_2_TX $35.;
informat AD_CITY_NM $30.;
informat AD_STATE_CD $2.;
informat AD_ZIP_CD $9.;
format STREET_AD_1_TX $35.;
format STREET_AD_2_TX $35.;
format AD_CITY_NM $30.;
format AD_STATE_CD $2.;
format AD_ZIP_CD $9.;
input
STREET_AD_1_TX $
STREET_AD_2_TX $
AD_CITY_NM $
AD_STATE_CD $
AD_ZIP_CD $
;
run;
If all of the variables are present then just removing the MISSOVER option should let SAS move to the next line to find the other fields. But if some of the records are missing some of the fields (ie there aren't enough commas) then this will cause SAS to get out of sync.
If the same number of fields are always on the first line then just put a / after the last field name in the first line in your INPUT statement.
If instead the issue is that some of the fields contain embedded end-of-line characters so that records are being split then you have a bigger problem.
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 16. 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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: