<?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: Problem with PROC SORT in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Problem-with-PROC-SORT/m-p/32468#M7819</link>
    <description>You must create a new SAS variable having the formatted value assigned, using the PUT function in an assignment statement typically.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
    <pubDate>Fri, 18 Dec 2009 11:40:49 GMT</pubDate>
    <dc:creator>sbb</dc:creator>
    <dc:date>2009-12-18T11:40:49Z</dc:date>
    <item>
      <title>Problem with PROC SORT</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problem-with-PROC-SORT/m-p/32467#M7818</link>
      <description>Hello everyone,&lt;BR /&gt;
&lt;BR /&gt;
I have a variable Region (which is a number from 1 to 6). I have added a format like so:&lt;BR /&gt;
[pre]PROC FORMAT library=PROJET.FORMATS;&lt;BR /&gt;
	value $Region&lt;BR /&gt;
	1='Pacific' 2='Americas' 3='Oceania' 4='Middle East' 5='Asia' 6='Africa';&lt;BR /&gt;
RUN;[/pre]&lt;BR /&gt;
&lt;BR /&gt;
I want to sort them alphabetically (Africa, Americas, ... , Pacific) and not numerically by ID (Pacific, Americas, ... Africa). I have typed this:&lt;BR /&gt;
&lt;BR /&gt;
[pre]proc sort data=TEMP; format Region $Region.; by Region; run;&lt;BR /&gt;
proc sort data=TEMP; by Region; run;[/pre]&lt;BR /&gt;
&lt;BR /&gt;
...and looked here:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/a000146878.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/a000146878.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
...but no luck. Any ideas? Apparently there's simply an option in SAS to do that.&lt;BR /&gt;
&lt;BR /&gt;
Thank-you in advance</description>
      <pubDate>Fri, 18 Dec 2009 10:36:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problem-with-PROC-SORT/m-p/32467#M7818</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-12-18T10:36:03Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with PROC SORT</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problem-with-PROC-SORT/m-p/32468#M7819</link>
      <description>You must create a new SAS variable having the formatted value assigned, using the PUT function in an assignment statement typically.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Fri, 18 Dec 2009 11:40:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problem-with-PROC-SORT/m-p/32468#M7819</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-12-18T11:40:49Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with PROC SORT</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problem-with-PROC-SORT/m-p/32469#M7820</link>
      <description>I'm afraid I simply don't understand what you mean. Do you mean that I should place another DATA STEP before the PROC SORT?</description>
      <pubDate>Fri, 18 Dec 2009 11:49:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problem-with-PROC-SORT/m-p/32469#M7820</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-12-18T11:49:52Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with PROC SORT</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problem-with-PROC-SORT/m-p/32470#M7821</link>
      <description>Ok to be more precise I actually simply need to output them sorted using the PROC MEANS method, so there is a statement/option in PROC MEANS that will allow me to sort it by formatted values (whilst keeping the dataset unchanged) then that will do fine.</description>
      <pubDate>Fri, 18 Dec 2009 12:01:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problem-with-PROC-SORT/m-p/32470#M7821</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-12-18T12:01:34Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with PROC SORT</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problem-with-PROC-SORT/m-p/32471#M7822</link>
      <description>Hi&lt;BR /&gt;
&lt;BR /&gt;
you can do this without another data step. Here is an example. Maybe your code does not work because you defined character format and try to apply the format to numeric variable.&lt;BR /&gt;
&lt;BR /&gt;
DATA station;&lt;BR /&gt;
INPUT c fc;&lt;BR /&gt;
CARDS;&lt;BR /&gt;
1 1&lt;BR /&gt;
2 2&lt;BR /&gt;
3 3&lt;BR /&gt;
4 4&lt;BR /&gt;
5 5&lt;BR /&gt;
6 6&lt;BR /&gt;
;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
PROC FORMAT;&lt;BR /&gt;
	value Region&lt;BR /&gt;
	1='Pacific' 2='Americas' 3='Oceania' 4='Middle East' 5='Asia' 6='Africa';&lt;BR /&gt;
RUN;&lt;BR /&gt;
proc print data=station;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
/*&lt;BR /&gt;
                                                           Obs    c    fc&lt;BR /&gt;
&lt;BR /&gt;
                                                            1     1     1&lt;BR /&gt;
                                                            2     2     2&lt;BR /&gt;
                                                            3     3     3&lt;BR /&gt;
                                                            4     4     4&lt;BR /&gt;
                                                            5     5     5&lt;BR /&gt;
                                                            6     6     6&lt;BR /&gt;
&lt;BR /&gt;
*/&lt;BR /&gt;
proc sort data=station out=station_s;&lt;BR /&gt;
	by descending fc;&lt;BR /&gt;
	format fc region.;&lt;BR /&gt;
run;&lt;BR /&gt;
proc print data=station_s;&lt;BR /&gt;
run;&lt;BR /&gt;
/*&lt;BR /&gt;
&lt;BR /&gt;
                                                      Obs    c    fc&lt;BR /&gt;
&lt;BR /&gt;
                                                       1     6    Africa     &lt;BR /&gt;
                                                       2     5    Asia       &lt;BR /&gt;
                                                       3     4    Middle East&lt;BR /&gt;
                                                       4     3    Oceania    &lt;BR /&gt;
                                                       5     2    Americas   &lt;BR /&gt;
                                                       6     1    Pacific    &lt;BR /&gt;
*/</description>
      <pubDate>Fri, 18 Dec 2009 12:19:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problem-with-PROC-SORT/m-p/32471#M7822</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-12-18T12:19:48Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with PROC SORT</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problem-with-PROC-SORT/m-p/32472#M7823</link>
      <description>Explore using the ORDER= parameter for PROC MEANS.  Otherwise, to follow-on my reply and your subsequent question about a DATA step -- yes, exactly.  If you are not interested in re-sequencing your data-values (another reply's suggestion), then you can use either a DATA step or a PROC SQL, along with the PUT function to create a new variable with the formatted value rather than the internal value of sort-ordering purpose.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Fri, 18 Dec 2009 12:52:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problem-with-PROC-SORT/m-p/32472#M7823</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-12-18T12:52:13Z</dc:date>
    </item>
  </channel>
</rss>

