0
votes

I have a blob of data from another database that I imported into SAS. The blob of data has multiple lines that starts with tags. I am able to write a piece of code to look for each tag and append them to a table column. Problem is, one of the tags has multiple lines of data (separated by carriage return/line feed) and I do not care about the first line. I only want the second line of data added to the table column (example below :NADR:). Can someone tell me how to modify this line of code to only look for the second line?

Example:

:NADR:SE12345

ADVANCED AUTO

:DF1:10/7/2018

Code:

Case When find(t1.Blob,":NADR:") > 0 then Strip(Substr(Substr(t1.Blob,find(t1.Blob,":NADR:")+6,300), 1, find(Substr(t1.Blob,find(t1.Blob,":NADR:")+6,300),":")-1)) End as Name

Thank you.

2

2 Answers

0
votes

Use the scan function to grab parts of a text. This example demonstrates using two different hex characters (those cr & lf) as part delimiters.

part2 = scan(blob,2,'0a0d'x);

Default behavior is that consecutive delimiters in the text in any order are considered a single delimiter. The m modifier in the fourth argument (not used above) of scan can change that behavior.

0
votes

Perhaps you can import each line individually and then just delete the lines with tags you don't want. For example:

if find(t1.Blob,":NADR:") > 0 then delete;

And the line with "Advanced Auto" is its own record. Unless something else about your data structure doesn't allow that.