The SAS Output Delivery System and reporting techniques

Another messy format to read

Not applicable
Posts: 0

Another messy format to read


I have a CSV file to read & I'm wondering if anyone can help. Here are the features of the file:

1. The file contains two types of record - one starting with 'H' and the other starting with 'R' - they are in different format so I have to read them into separate datasets. I used '@' to determine the type of the record and created two datasets (one for H and one for R)

2. The H record contains about 85 variables to read. Some are missing (especially the last one) so I used DLM=',', DSD and MISSOVER option. The problem is - the H record's length can vary depends on the record and it stops at the first 200th columns and continue on the next line. So for example - if the end of the first line contains a time variable (11:35), it cuts off at 200th and continue on the next line therefore messing up the data. (ie. 1 (at 200th column of the first line) and 1:35 (the start of the second line) for 11:35). This record could continue to the third line as well if the record is really long.

Does anybody see a possible solution to this???

Posts: 9,367

Re: Another messy format to read

Posted in reply to deleted_user
This is not an ODS/Reporting issue, so much as it is a DATA step/INFILE/INPUT issue. Tech Support is probably your best bet for help with this problem as they can actually look at your data file and come up with the appropriate suggestions.

For example, on some operating systems, you can put an LRECL= option on your INFILE statement to increase the size of the buffer for reading the "raw" data. You can also use the LENGTH= option in order to create a variable that tells you the length of the current "line of data" in the buffer. Then, you can use that Length variable with the VARYING informat in order to read the correct length of the record and not go over to the next line. In addition there are some other options you can specify on the INFILE statement that might help you, but it really depends a lot on your operating system, your data, etc.

The folks in Tech Support are the best ones to help you with this problem. To contact Tech Support, refer to:

Good luck!
Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation