LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (June 2000, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 21 Jun 2000 11:54:05 +0200
Reply-To:   Jim Groeneveld <J.Groeneveld@ITGROUPS.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Jim Groeneveld <J.Groeneveld@ITGROUPS.COM>
Subject:   Re: sort, without sort, unsort?
Comments:   To: paula <icj808@USWEST.NET>
Content-Type:   text/plain; charset="iso-8859-1"

Paula (and others),

Let me say that instead of using PROC SORT I often use PROC FREQ for sorting, using the OUT= option with the TABLES statement. I only need to specify the desired variables to keep in the specified order. PROC FREQ gives me unique cases anyway with the variable Count as the weights. Additionally I can specify 4 different ordering types [ORDER= INTERNAL | FREQ | DATA | FORMATTED] and thus specifically select between unformatted and formatted values. The last features is most important in (rare) cases where two non-consecutive unformatted values have equally formatted values.

In any case PROC FREQ does not need a sorted dataset as input (it "sorts" it itself), but it may run somewhat faster if it obtains an already sorted dataset. But I suspect the total processing time for explicitely SORTing and running FREQ is more than FREQ with an unsorted dataset) only. Besides, should you sort an already existing dataset, don't create an extra scratch dataset to run PROC SORT on as in: date to_be_sorted; set unsorted; RUN; proc sort; by something; run; but instruct PROC SORT to read one file and write the other one, as in: proc sort data=unsorted out=sorted; by something; run;

This saves time AND disk space. HTH

Regards - Jim. -- Y. (Jim) Groeneveld, MSc IMRO TRAMARKO tel. +31 412 407 070 senior statistician, P.O. Box 1 fax. +31 412 407 080 head IT department 5350 AA BERGHEM IMRO TRAMARKO: a CRO J.Groeneveld@ITGroups.com the Netherlands in clinical research

My computer does not need me at all, but I can't do without it anymore.

> -----Original Message----- > From: paula [SMTP:icj808@USWEST.NET] > Sent: Wednesday, June 21, 2000 12:33 AM > To: SAS-L@LISTSERV.UGA.EDU > Subject: Re: sort, without sort, unsort? > > Let rephrase the problem. Sorry about the confusion. > > There are such steps as follow > /*?????????step 1*/ > libname test 'c:\sas\'; > data test.sort; > infile .....; > input va2.......; > > proc sort; > by va2; > run; > > Proc freq; > run; > > /*?????????step 2*/ > > libname test 'c:\sas\'; > data test.sort; > infile .....; > input va2.......; > > Proc freq; > run; > > The only difference is that step 2 does have include the proc sort. The > proc > freq in both steps is a kind of "moot". it is used here simply to indicate > other procs will be used against test.sort, but won't change the data set > so > that the resulting set appears "de-sorted". But Step 2 is executed After > step 1 is. The question: I don't recall there is any SAS proc that demands > the data set be "de-sort" first. In what form the test.sort will show > after > the two steps are run? will SAS overwrite the sorted test.sort with a > unsorted version after Step 2 is executed? I can run a simple test to find > out, what is the theory? > > I am construing some "Macro-management". If, when Step 2 is being > executed, > SAS sees the preexisting copy of the test.sort is already sorted, it > preserves the sorted copy and proceeds onto other procs, one plan could be > feasible to plan sorting massive SAS data sets in better managed computing > environments, rather than sorting them on the fly. On the fly, when the > data > sets involved are large in size, they bottleneck decision support process > at > bad costs. I am trying to set up a type of pre-processing process to try > best to feed analysts with sorted data sets. While not predicting exactly > what questions execs may pop up, 90% of them are well expected. > > I suspect SAS will hand me a unsorted copy eventually, since it runs > sequentially. If so, is there any options is SAS I can use to achieve what > I > want? Of course, referencing different libraries is OK, but I am not > particularly fond of populating too many large SAS data sets. > > TIA > > Paula D > > > "paula" <icj808@uswest.net> wrote in message > news:KwD35.471$np.13745@news.uswest.net... > > I want to sort, so I wrote, > > > > date to_be_sorted; > > set unsorted; > > > > proc sort; > > by something; > > run; > > > > So I got my sorted data set, to_be_sorted. Then I did some data > manipulation > > so that the the records remain sorted by the variables. > > > > The second day I came back. I forgot what manipulation I did yesterday. > So > I > > redo it. But, I somehow omit this section > > > > proc sort; > > by something; > > run; > > > > Well, the manipulation here does not require the data set to be sorted > > first. So I did not have any error message. I got what I want. > > > > The question is about the underlying process: Does SAS actually replace > the > > unsorted dataset unsorted into the to_be_sorted in the second time and > get > > to the same results, and after the second day experience, I end up with > a > > unsorted to_be_sorted? Or a sorted to_be_sorted? > > > > Paula D > > > > > > > >


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