<?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: Sorting categorical variables with PROC SORT in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Sorting-categorical-variables-with-PROC-SORT/m-p/427227#M105343</link>
    <description>&lt;P&gt;And the question is?&lt;/P&gt;
&lt;P&gt;"I'm trying to do the following the PROC SORT" doesn't make much sense.&lt;/P&gt;
&lt;P&gt;You need to check your example data. The way you read your data you do not have a value of "Westchester" only "westches" . $ without an informat or similar to tell SAS the variable is longer than 8 characters results in truncated data.&lt;/P&gt;
&lt;PRE&gt;DATA foo;
  INPUT name $12.;
  DATALINES;
nassau
suffolk
westchester
putnam
;
RUN;&lt;/PRE&gt;
&lt;P&gt;If you were not getting expected results you should show the results you were getting and what you expected&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you attempting to use the proc sql instead of proc sort?&lt;/P&gt;</description>
    <pubDate>Fri, 12 Jan 2018 15:52:00 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2018-01-12T15:52:00Z</dc:date>
    <item>
      <title>Sorting categorical variables with PROC SORT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sorting-categorical-variables-with-PROC-SORT/m-p/427216#M105340</link>
      <description>&lt;P&gt;I'm trying to do the following with PROC SORT:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;DATA FOO;
  INPUT name $;
  DATALINES;
nassau
suffolk
westchester
putnam
;
RUN;

PROC SQL;
  SELECT *
  FROM FOO
  ORDER BY CASE name
    WHEN 'westchester' THEN 1
    WHEN 'putnam' THEN 2
    WHEN 'suffolk' THEN 3
    WHEN 'nassau' THEN 4
  END;
QUIT;


&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 15:41:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sorting-categorical-variables-with-PROC-SORT/m-p/427216#M105340</guid>
      <dc:creator>tomcmacdonald</dc:creator>
      <dc:date>2018-01-12T15:41:05Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting categorical variables with PROC SORT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sorting-categorical-variables-with-PROC-SORT/m-p/427219#M105342</link>
      <description>&lt;P&gt;You'd still need to create those new variables in a prior step and then sort accordingly.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;AFAIK there's no way to incorporate that into the PROC SORT directly, which is what I assume you're asking.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/142145"&gt;@tomcmacdonald&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I'm trying to do the following with PROC SORT:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;DATA FOO;
  INPUT name $;
  DATALINES;
nassau
suffolk
westchester
putnam
;
RUN;

PROC SQL;
  SELECT *
  FROM FOO
  ORDER BY CASE name
    WHEN 'westchester' THEN 1
    WHEN 'putnam' THEN 2
    WHEN 'suffolk' THEN 3
    WHEN 'nassau' THEN 4
  END;
QUIT;


&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 15:45:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sorting-categorical-variables-with-PROC-SORT/m-p/427219#M105342</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-12T15:45:40Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting categorical variables with PROC SORT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sorting-categorical-variables-with-PROC-SORT/m-p/427227#M105343</link>
      <description>&lt;P&gt;And the question is?&lt;/P&gt;
&lt;P&gt;"I'm trying to do the following the PROC SORT" doesn't make much sense.&lt;/P&gt;
&lt;P&gt;You need to check your example data. The way you read your data you do not have a value of "Westchester" only "westches" . $ without an informat or similar to tell SAS the variable is longer than 8 characters results in truncated data.&lt;/P&gt;
&lt;PRE&gt;DATA foo;
  INPUT name $12.;
  DATALINES;
nassau
suffolk
westchester
putnam
;
RUN;&lt;/PRE&gt;
&lt;P&gt;If you were not getting expected results you should show the results you were getting and what you expected&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you attempting to use the proc sql instead of proc sort?&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 15:52:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sorting-categorical-variables-with-PROC-SORT/m-p/427227#M105343</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-01-12T15:52:00Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting categorical variables with PROC SORT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sorting-categorical-variables-with-PROC-SORT/m-p/427231#M105344</link>
      <description>Sorry, I didn't test the code above. I'm trying to sort based on an assigned priority of a categorical variable solely using PROC SORT without having to create a temporary variable.</description>
      <pubDate>Fri, 12 Jan 2018 15:58:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sorting-categorical-variables-with-PROC-SORT/m-p/427231#M105344</guid>
      <dc:creator>tomcmacdonald</dc:creator>
      <dc:date>2018-01-12T15:58:43Z</dc:date>
    </item>
  </channel>
</rss>

