Hi @teelov
After a brief look at the documentation, it seems even more complicated. I have a suspicion that a given flow (or source, eg. D0086) contains a hierarchial structure of groups with the possibility of multiple occurrences like this:
Have XYZ D1234 001 Meter A 002 Reading 1 002 Reading 2 002 Reading 3 001 Meter B 002 Reading 1 002 Reading 2
Wanted D1234 A 1 D1234 A 2 D1234 A 3 D1234 B 1 D1234 B 2
If this is the case, then a file record is not a stand-alone unit, as ID values from one group must be retained to provide reference-ID's for the following groups.
A way of handling this is with this skeleton code, where the file is transformed to a relational structure:
data
meter (keep = Meter_iD ...)
reading (keep = Meter_ID Rreading ...);
length Meter_ID $10 ... ;
retain Meter_ID;
infile ..;
input;
if scan(_infile_,1,'|') = '001' then do;
Meter_ID = scan(_infile_,2,'|');
...
output meter;
end;
if scan(_infile_,1,'|') = '002' then do;
Reading = input(scan(_infile_,2,'|');
...
output reading;
end;
run;
... View more