BookmarkSubscribeRSS Feed
SASPhile
Quartz | Level 8


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;

1 REPLY 1
Tom
Super User Tom
Super User

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.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1445 views
  • 0 likes
  • 2 in conversation