It's just data, frankly.
If you have multiple DX1 records/segments, you will need to adapt your SAS program to declare some maximum of "n" combined sets of SAS variables in your output file structure -- using RETAINs but also ideally using ATTRIB/LENGTH stmts to declare the variable attributes (coded before the INPUT and RETAIN stmts). So if you intend to capture and output up to 3 sets of DX1 segments, you must have declared the three combinations of variables, each identified uniquely in your program. Also, your program will need to detect when it is the first, second, third DX1 record and populate the corresponding segment set, such as detecting a blank or missing variable value or by using some temporary SAS variable as a flag indicating how many DX1 segments have been read.
Remember, this is straightforward SAS DATA step programming reading some external data, whether HL7 or otherwise -- the key is that you have shared the input side, but, unfortunately, not the desired output side as an illustration of your SAS dataset/variable structure sample.
Scott Barry
SBBWorks, Inc.