If the data are sorted by barcodeid, then this data step will also work:
data have;
input BarcodeID :$5. Date :mmddyy10. Minutes Species :$7. Length ;
datalines;
A1234 5/15/2020 15.00 Walleye 180
A1234 5/15/2020 15.00 Walleye 350
A1234 5/15/2020 15.00 Sauger 175
B1234 5/15/2020 15.00 Walleye 400
B1234 5/15/2020 15.00 Walleye 500
C1234 5/15/2020 15.00 NoFish .
run;
data want (drop=_:);
array species_array {2} $7 _temporary_ ("Walleye", "Sauger");
_species_list=catx(' ',of species_array{*});
/* Read and output catches, and pare down _species_list accordingly*/
do until (last.barcodeid);
set have;
by barcodeid;
_species_list=left(tranwrd(_species_list,trim(species),' '));
count=1;
if species^='NoFish' then output;
end;
/* At end of barcodeid, use _species_list to output needed dummy records */
count=0;
do while (_species_list^=' ');
length=.;
species=scan(_species_list,1,' ');
output;
_species_list=left(tranwrd(_species_list,trim(species),' '));
end;
run;
... View more