Date: Mon, 8 Sep 2003 11:41:55 +0100 Roland "SAS(r) Discussion" Roland Universe Monitors bubble sort with SAS

I've been reading up on and trying to understand the "bootstrap" technique as applied to analysis of clinical data and it struck me that with random sampling with maybe millions of iterations it could be faster to do all the analysis you can within the same data step and never leave it. Getting a median value and the 95% limits is a problem unless you can sort your values so I wrote a simple bubble sort to do this. I wonder if I am going in the right direction with this. I am trying to make the process as efficient as possible and trying to limit the number of observations being passed out of a data step and on to other procedures. However, I don't want to compromise and analysis that must be done on the data. Perhaps some kind statistician who works on analysis of clinical trials and has a need for this sort of coded techniques to be developed could point me in the right direction.

Here is the bubble sort for you to play around with:

data _null_; array _val {20} 8 (20*0);

*- assign a random value to all the cells and display -; do i=1 to 20; _val(i)=floor(ranuni(9)*500); put _val(i)=; end;

*- bubble sort -; max=dim(_val); swapdone=1; do while(max > 1 and swapdone); swapdone=0; do i=1 to (max-1); if _val(i)>_val(i+1) then do; store=_val(i+1); _val(i+1)=_val(i); _val(i)=store; swapdone=1; end; end; max=max-1; end;

*- display the final sorted order -; do i=1 to 20; put _val(i)=; end; run;

-- "Today's mighty oak is just yesterday's nut, that held its ground." - David Icke

Back to: Top of message | Previous page | Main SAS-L page