| Date: | Mon, 9 Feb 2004 12:15:42 -0500 |
| Reply-To: | Howard Schreier <Howard_Schreier@ITA.DOC.GOV> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Howard Schreier <Howard_Schreier@ITA.DOC.GOV> |
| Subject: | Re: Returning to original sort order |
|---|
Yes. If the initial order is not inherent the values of one or more
variables, it's pretty much necessary to add a sequence variable.
So far, so good.
With or without the added variable, Pat's code fails, and even after
obvious and plausible fixes are made, it does not generate the output
shown. PROC RANK does not operate on character variables.
On Mon, 9 Feb 2004 13:04:52 GMT, Arthur Tabachneck <art297@NETSCAPE.NET>
wrote:
>Pat,
>
>You could just create a new variable, e.g. recnum, when you initially read
>the file.
>
>Art
>-------
>data one;
>input ID $ Peettype $ _NAME_ $ Value;
>recnum=_n_;
>cards;
>1 Comp N10 1000
>1 Comp A11 1200
>1 Comp F12 600
>1 Comp S13 800
>2 Comp N10 900
>2 Comp A11 1500
>2 Comp F12 980
>2 Comp S13 1900
>;
>run;
>----
>"Pat Moore" <pat.moore@UAA.ALASKA.EDU> wrote in message
>news:200402090810.i198AxI08331@listserv.cc.uga.edu...
>> I have a file which is arranged in a particular order:
>>
>> ID Peettype _NAME_ Value
>> 1 Comp N10 1000
>> 1 Comp A11 1200
>> 1 Comp F12 600
>> 1 Comp S13 800
>> 2 Comp N10 900
>> 2 Comp A11 1500
>> 2 Comp F12 980
>> 2 Comp S13 1900
>> etc. (id is a character variable)
>>
>> I'm using proc rank to rank the values within groups:
>>
>> proc rank data=prerank9802 out=rank9802 ties=low;
>> by peertype _name_;
>> var _numeric_;
>> run;
>>
>> This reorganizes the file alphabetically by _name_:
>> 1 Comp A11 1200 1
>> 1 Comp F12 600 2
>> 1 Comp N10 1000 2
>> 1 Comp S13 800 2
>> 2 Comp A11 900 2
>> 2 Comp F12 1500 1
>> 2 Comp N10 1900 1
>> 2 Comp S13 980 1
>>
>> I need to keep everything together and restore the order after the
ranking
>> step. I think an index might do it, but have never worked with one. Or,
>> maybe I have to create an order variable, in which case, I'm not sure how
>> to assign a set of sequential numbers to a series of observations.
>>
>> Confused, I am,
>>
>> Pat Moore
>> mailto:pmoore@uaa.alaska.edu
|