From: demin on 28 Oct 2009 14:03 In proc freq, can I specify order=data and order=freq in proc freq? I want the data order as the input data set, because the data are: Q1R1C1 Q1R1C2 Q2PR2C8 Q2TR1C1 Q2TR1C2 Q2TR10C1 Q2TR10C2 Q12TP1C1 Q12TP1C2 Q12TP1C10 .... but i also want the result display by descending frequency count at the same time. If i specify order=freq, then the order of items is wrong. how to solve this? thanks.
From: "Terjeson, Mark" on 28 Oct 2009 14:28 Hi Demin, If the original ordering is not normal alpha or numeric ordering, and If you want the result to be the same order as the original, the later makes it easy: When your input dataset is built, or subsequent, you can use the observation number _N_ and save it to a new variable in the dataset and maybe call it something like "sortorder". e.g. to make an ordering variable (if incoming is in the proper order) data intermediate_dataset; set incoming_dataset; sortorder = _N_; run; Then after your processing you can order by or sort by the new sortorder number and it will match your original non-standard ordering. If you do aggregating or need to process your data without the new sortorder variable to allow proper rollups, ets. then if your resultant datasets still have the key field shown below then you can always attach the sortorder back to the newer dataset via the key field and the sort the sortorder field number. Hope this is helpful. Mark Terjeson Investment Business Intelligence Investment Management & Research Russell Investments 253-439-2367 Russell Global Leaders in Multi-Manager Investing -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L(a)LISTSERV.UGA.EDU] On Behalf Of demin Sent: Wednesday, October 28, 2009 11:04 AM To: SAS-L(a)LISTSERV.UGA.EDU Subject: Can I specify order=data and order=freq in proc freq? In proc freq, can I specify order=data and order=freq in proc freq? I want the data order as the input data set, because the data are: Q1R1C1 Q1R1C2 Q2PR2C8 Q2TR1C1 Q2TR1C2 Q2TR10C1 Q2TR10C2 Q12TP1C1 Q12TP1C2 Q12TP1C10 .... but i also want the result display by descending frequency count at the same time. If i specify order=freq, then the order of items is wrong. how to solve this? thanks.
From: rjf2 on 28 Oct 2009 17:10 > From: demin > Sent: Wednesday, October 28, 2009 2:04 PM > Subject: Can I specify order=data and order=freq in proc freq? > > In proc freq, can I specify order=data and order=freq in proc freq? > I want the data order as the input data set, because the data are: > Q1R1C1 > Q1R1C2 > Q2PR2C8 > Q2TR1C1 > Q2TR1C2 > Q2TR10C1 > Q2TR10C2 > Q12TP1C1 > Q12TP1C2 > Q12TP1C10 > ... > but i also want the result display by descending frequency count at > the same time. > If i specify order=freq, then the order of items is wrong. how to > solve this? > thanks. you want to RTFM on the order= option. no, you cannot specify both order=data produces output that reflects the first occurrences of the values order = data sorts the output by descending count. default: order = internal, same as proc sort. PROC Freq data = Library.MyData order = data; tables WhichVar / list missing out = Work.Freq_order_data; PROC Sort data = Work.Freq_order_data out = Work.Freq_order_freq; by desending Count; PROC Print data = Work.Freq_order_freq; run; Ron Fehd the macro maven CDC Atlanta GA USA RJF2 at cdc dot gov
|
Pages: 1 Prev: sas Access question??? Next: Remote session can't connect to oracle |