05-14-2015 07:07 AM
I have a text file I am trying to read into sas but I can't get it to read in properly. The problem is that loads of the rows have blank fields so when I read in using this code, the code skips over the blanks and all the values are squeezed into the first few columns. The structure of the txt file is such that each column is separated by a blank. so the first few columns of the first rows looks like:
Key............ .......Quote No Cover
You will see that the second row in the above example has nothing under Key. I want the data to be read in so that it leaves a cell blank if there is nothing there.
Here is the code I'm using:
infile FLEET dsd lrecl = 10000 firstobs=2;
05-14-2015 07:18 AM
There are different input styles depending on how your source data file looks like. You write that "each column is separated by a blank" but then the data you're posting looks like the data is on certain positions.
The issue with "each column is separated by a blank" is "missing values". So in such a case would we have 3 consecutive blanks? Or what would tell us that a sequence of blanks actually isn't just a delimiter for a column. On the other hand if your data is "positional" (as it looks like in the data you've posted) then reading this data would be quite simple.
I suggest you attach a text file with a few rows of your data. That would make it much easier for us to give you some advice of how to read this data into SAS.
05-14-2015 07:28 AM
I have attached the actual text file with the first 20 rows.
Also, is there a simple way of duplicating the key until it reaches the next values so
05-14-2015 07:18 AM
If the fields are blank delimited the DSD option is wrong, not needed.
If the fields are blank delimited and the missing values are not marked (also blank) then you cannot use LIST input.
You might be able to use column input.
You might have delimiter that cannot see like a tab.
You need to provide complete information about what you have.