<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: proc sort with form of Pre 1995, 1995, 1996.. in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/proc-sort-with-form-of-Pre-1995-1995-1996/m-p/38438#M9851</link>
    <description>Thanks for the reply.&lt;BR /&gt;
&lt;BR /&gt;
Your way is actually the same as define those in the data step. &lt;BR /&gt;
So in the dataset they still appear to be pre 1995, &lt;BR /&gt;
                                                          1996, 1997......&lt;BR /&gt;
&lt;BR /&gt;
When you sort those, it returns &lt;BR /&gt;
1996&lt;BR /&gt;
1997&lt;BR /&gt;
1998&lt;BR /&gt;
.....&lt;BR /&gt;
pre 1995. &lt;BR /&gt;
&lt;BR /&gt;
But I need it to be&lt;BR /&gt;
pre 1995&lt;BR /&gt;
1996&lt;BR /&gt;
1997&lt;BR /&gt;
.....</description>
    <pubDate>Fri, 08 Jan 2010 16:58:07 GMT</pubDate>
    <dc:creator>Fred_Gavin</dc:creator>
    <dc:date>2010-01-08T16:58:07Z</dc:date>
    <item>
      <title>proc sort with form of Pre 1995, 1995, 1996..</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sort-with-form-of-Pre-1995-1995-1996/m-p/38436#M9849</link>
      <description>I have the data with years defined as pre 1995, 1995, 1996 and so on. &lt;BR /&gt;
&lt;BR /&gt;
the sort procedure gives the results sorting single year first, and put pre 1995 at last. &lt;BR /&gt;
&lt;BR /&gt;
How should I make the sorting procedure as defined ? &lt;BR /&gt;
&lt;BR /&gt;
Pre 1995&lt;BR /&gt;
1995&lt;BR /&gt;
1996&lt;BR /&gt;
...&lt;BR /&gt;
&lt;BR /&gt;
Many Thanks</description>
      <pubDate>Fri, 08 Jan 2010 16:21:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sort-with-form-of-Pre-1995-1995-1996/m-p/38436#M9849</guid>
      <dc:creator>Fred_Gavin</dc:creator>
      <dc:date>2010-01-08T16:21:32Z</dc:date>
    </item>
    <item>
      <title>Re: proc sort with form of Pre 1995, 1995, 1996..</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sort-with-form-of-Pre-1995-1995-1996/m-p/38437#M9850</link>
      <description>One of the solution is&lt;BR /&gt;
&lt;BR /&gt;
proc format;&lt;BR /&gt;
   value $yr  '10'='pre 1995';&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data test;&lt;BR /&gt;
  set test;&lt;BR /&gt;
  if year='pre 1995' then year = '10';&lt;BR /&gt;
  format year yr.;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Sandy.</description>
      <pubDate>Fri, 08 Jan 2010 16:32:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sort-with-form-of-Pre-1995-1995-1996/m-p/38437#M9850</guid>
      <dc:creator>Sandhya</dc:creator>
      <dc:date>2010-01-08T16:32:17Z</dc:date>
    </item>
    <item>
      <title>Re: proc sort with form of Pre 1995, 1995, 1996..</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sort-with-form-of-Pre-1995-1995-1996/m-p/38438#M9851</link>
      <description>Thanks for the reply.&lt;BR /&gt;
&lt;BR /&gt;
Your way is actually the same as define those in the data step. &lt;BR /&gt;
So in the dataset they still appear to be pre 1995, &lt;BR /&gt;
                                                          1996, 1997......&lt;BR /&gt;
&lt;BR /&gt;
When you sort those, it returns &lt;BR /&gt;
1996&lt;BR /&gt;
1997&lt;BR /&gt;
1998&lt;BR /&gt;
.....&lt;BR /&gt;
pre 1995. &lt;BR /&gt;
&lt;BR /&gt;
But I need it to be&lt;BR /&gt;
pre 1995&lt;BR /&gt;
1996&lt;BR /&gt;
1997&lt;BR /&gt;
.....</description>
      <pubDate>Fri, 08 Jan 2010 16:58:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sort-with-form-of-Pre-1995-1995-1996/m-p/38438#M9851</guid>
      <dc:creator>Fred_Gavin</dc:creator>
      <dc:date>2010-01-08T16:58:07Z</dc:date>
    </item>
    <item>
      <title>Re: proc sort with form of Pre 1995, 1995, 1996..</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sort-with-form-of-Pre-1995-1995-1996/m-p/38439#M9852</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
See what is the first value of the sorted order.  Give a value lesser that that instead of 10.&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Sandy.</description>
      <pubDate>Fri, 08 Jan 2010 17:08:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sort-with-form-of-Pre-1995-1995-1996/m-p/38439#M9852</guid>
      <dc:creator>Sandhya</dc:creator>
      <dc:date>2010-01-08T17:08:20Z</dc:date>
    </item>
    <item>
      <title>Re: proc sort with form of Pre 1995, 1995, 1996..</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sort-with-form-of-Pre-1995-1995-1996/m-p/38440#M9853</link>
      <description>Oh, it works now.&lt;BR /&gt;
&lt;BR /&gt;
Thank you very much.</description>
      <pubDate>Fri, 08 Jan 2010 17:32:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sort-with-form-of-Pre-1995-1995-1996/m-p/38440#M9853</guid>
      <dc:creator>Fred_Gavin</dc:creator>
      <dc:date>2010-01-08T17:32:46Z</dc:date>
    </item>
    <item>
      <title>Re: proc sort with form of Pre 1995, 1995, 1996..</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sort-with-form-of-Pre-1995-1995-1996/m-p/38441#M9854</link>
      <description>Yet another way of performing a sort by formatted values, would be:&lt;BR /&gt;
[pre]&lt;BR /&gt;
* create format;&lt;BR /&gt;
data _FORMAT;&lt;BR /&gt;
     set INDATA (rename=(YEAR=START));&lt;BR /&gt;
	 keep FMTNAME TYPE HLO START END LABEL;&lt;BR /&gt;
     retain FMTNAME 'YR'&lt;BR /&gt;
            TYPE 'C'&lt;BR /&gt;
            HLO '';     &lt;BR /&gt;
	 END=START;&lt;BR /&gt;
	 LABEL=put(input(START,??best.),best.); * convert value to numeric;&lt;BR /&gt;
run;&lt;BR /&gt;
proc format cntlin=_FORMAT;&lt;BR /&gt;
run ;&lt;BR /&gt;
&lt;BR /&gt;
* fomatted sort;&lt;BR /&gt;
proc sql;&lt;BR /&gt;
create table OUTDATA as&lt;BR /&gt;
select * from INDATA order by put(YEAR,$YR.);&lt;BR /&gt;
quit; &lt;BR /&gt;
[/pre]&lt;BR /&gt;
With this any non pure digit value of YEAR will be sorted as the lowest value (hence "pre 1995").&lt;BR /&gt;
&lt;BR /&gt;
Cheers from Portugal.&lt;BR /&gt;
&lt;BR /&gt;
Daniel Santos @ &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;</description>
      <pubDate>Fri, 08 Jan 2010 18:12:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sort-with-form-of-Pre-1995-1995-1996/m-p/38441#M9854</guid>
      <dc:creator>DanielSantos</dc:creator>
      <dc:date>2010-01-08T18:12:11Z</dc:date>
    </item>
    <item>
      <title>Re: proc sort with form of Pre 1995, 1995, 1996..</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sort-with-form-of-Pre-1995-1995-1996/m-p/38442#M9855</link>
      <description>'guess a choice of preferred method depends on more than we know. I have often had to group information into non-equal time bands (like pre1995, 1995-2000, 2001,2002,2003, ... lastyear, months of this year). &lt;BR /&gt;
With that requirement, I found date-type class variables in the reporting procedures needed no alteration, just to be formatted with a simple user format, like:[pre]&lt;BR /&gt;
proc format ;&lt;BR /&gt;
  value clDate&lt;BR /&gt;
           low - '31dec1994'd = 'pre- 1995'&lt;BR /&gt;
   '1jan1995'd - '31dec2000'd = '1995-2000'&lt;BR /&gt;
   '1jan2001'd - "%sysfunc( intnx( year, "&amp;amp;sysdate"d, -1,e ), date9)"d =[year4.]&lt;BR /&gt;
   "%sysfunc( intnx( year, "&amp;amp;sysdate"d, 0,b ), date9)"d - high = [monyy7.]&lt;BR /&gt;
run ;[/pre]Then given a sas data set with tran_date, I can get stats in this collection of un-equal time bands with something like[pre]proc tabulate data= my_tran_data missing ;&lt;BR /&gt;
   class  tran_date ;&lt;BR /&gt;
   format tran_date clDate. ;&lt;BR /&gt;
   var    purchase  sale actual forecast ;&lt;BR /&gt;
   table ( tran_date all), (purchase  sale actual forecast)&lt;BR /&gt;
            *sum=' '*f= comma11./ rts=15 ;&lt;BR /&gt;
run ;[/pre]&lt;BR /&gt;
use variables that are more relevant to you&lt;BR /&gt;
 &lt;BR /&gt;
PeterC&lt;BR /&gt;
[beware untested code]</description>
      <pubDate>Sat, 09 Jan 2010 11:52:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sort-with-form-of-Pre-1995-1995-1996/m-p/38442#M9855</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2010-01-09T11:52:38Z</dc:date>
    </item>
  </channel>
</rss>

