In case anyone can use this:

I needed to trim my select list to specific number, usually I take
  my ACTUAL/NEED and then do a SAMPLED # but I ran into a problem
  when my NEED was fairly close to my ACTUAL, and you can't use 
  SAMPLED with a fractional number (I needed 1.25)

You sort and save your list, run this program, give it a new list
  name (or overwrite your original if your so bold), and the
  count you want to achieve.

I tested it a few times and it was exact, but given the nature of
  decimals, it might be off 1 or 2.

George


PRINT "What is the SOURCE List Name :":;INPUT SLIST
PRINT "What is the OUTPUT List Name :":;INPUT OLIST
*
PRINT "What is the maximum count :":;INPUT MAX
*
OPEN "","&SAVEDLISTS&" TO F.SL ELSE STOP "NO &SAVEDLISTS&"
*
READ XDATA FROM F.SL,SLIST ELSE STOP "NO ":SLIST:" LIST FOUND"
UU=DCOUNT(XDATA,CHAR(254))
IF UU <= MAX THEN STOP "LIST HAS ":UU:" ENTRIES NOW"
*
SKIP=UU/MAX
NEXTKEEP=SKIP
IF NEXTKEEP#INT(NEXTKEEP) THEN NEXTCHECK=INT(NEXTKEEP)+1 ELSE NEXTCHECK=NEXTKEEP
*
T=1
KEEP=""
*
LOOP
   IF T > UU THEN EXIT
   IF T = NEXTCHECK THEN
      KEEP<-1>=XDATA<T>
      NEXTKEEP=NEXTKEEP+SKIP
      IF NEXTKEEP#INT(NEXTKEEP) THEN NEXTCHECK=INT(NEXTKEEP)+1 ELSE 
NEXTCHECK=NEXTKEEP
   END
   T=T+1
REPEAT
WRITE KEEP ON F.SL,OLIST
STOP
END
-------
u2-users mailing list
[email protected]
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to