/* REXX DROPDUP Eliminate duplicate lines in a dataset. */ address ISREDIT 'macro (parms)' sw.0batch = Sysvar("SYSENV") = "BACK" if sw.0batch then rc = Trace("R") push parms; pull parms sw.0quiet = Wordpos("QUIET",parms) > 0 sw.0disp = Wordpos("DISP",parms) > 0 if sw.0disp then sw.0quiet = '1' "(lmar rmar) = BOUNDS" lp = Wordpos("LEN",parms); if lp > 0 then len = Word(parms,lp+1) else len = rmar "F P'=' LAST" "(lastline) = CURSOR" "CURSOR = 1" rc = 0 "(prev) = LINE 1" do i = 1 to lastline-1 j = i + 1 if j > lastline then leave "(this) = LINE" j do while (Left(prev,len) = Left(this,len)) & rc = 0 if sw.0disp then do; say "Nominally deleted: *"j"*" Strip(this) j = j + 1; i = i + 1; end else do "DELETE" j lastline = lastline - 1 end if sw.0quiet then nop; else, say "Deleted" j", Lastline now" lastline"." "(this) = LINE" j end prev = this end /* i */ "CURSOR = 1 1" if sw.0batch then "END" exit /*@ DROPDUP */