<?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 Max/Min of character column with proc means in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Max-Min-of-character-column-with-proc-means/m-p/539676#M148740</link>
    <description>&lt;P&gt;How can I get the maximum of a character field using proc means? I get "ERROR: Variable TERM_CODE in list does not match type prescribed for this list", with the following code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=stulasr.vday_summary_eg max;

var TERM_CODE;

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would find it surprising if proc means were unable to generate order statistics for a alphanumeric sample. proc sql works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ultimately, I'm trying to create a character macro variable for downstream use in a proc sql step. Perhaps there's a better approach in general.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 01 Mar 2019 16:21:11 GMT</pubDate>
    <dc:creator>tfarkas</dc:creator>
    <dc:date>2019-03-01T16:21:11Z</dc:date>
    <item>
      <title>Max/Min of character column with proc means</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Max-Min-of-character-column-with-proc-means/m-p/539676#M148740</link>
      <description>&lt;P&gt;How can I get the maximum of a character field using proc means? I get "ERROR: Variable TERM_CODE in list does not match type prescribed for this list", with the following code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=stulasr.vday_summary_eg max;

var TERM_CODE;

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would find it surprising if proc means were unable to generate order statistics for a alphanumeric sample. proc sql works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ultimately, I'm trying to create a character macro variable for downstream use in a proc sql step. Perhaps there's a better approach in general.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2019 16:21:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Max-Min-of-character-column-with-proc-means/m-p/539676#M148740</guid>
      <dc:creator>tfarkas</dc:creator>
      <dc:date>2019-03-01T16:21:11Z</dc:date>
    </item>
    <item>
      <title>Re: Max/Min of character column with proc means</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Max-Min-of-character-column-with-proc-means/m-p/539677#M148741</link>
      <description>&lt;P&gt;Max/Min of a character column is undefined.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC MEANS will not operate on character variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you give us a small example of the data you have and the output you want?&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2019 16:17:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Max-Min-of-character-column-with-proc-means/m-p/539677#M148741</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-03-01T16:17:22Z</dc:date>
    </item>
    <item>
      <title>Re: Max/Min of character column with proc means</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Max-Min-of-character-column-with-proc-means/m-p/539680#M148743</link>
      <description>Thanks. Edited my post.</description>
      <pubDate>Fri, 01 Mar 2019 16:21:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Max-Min-of-character-column-with-proc-means/m-p/539680#M148743</guid>
      <dc:creator>tfarkas</dc:creator>
      <dc:date>2019-03-01T16:21:31Z</dc:date>
    </item>
    <item>
      <title>Re: Max/Min of character column with proc means</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Max-Min-of-character-column-with-proc-means/m-p/539682#M148744</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Ultimately, I'm trying to create a character macro variable for downstream use in a proc sql step. Perhaps there's a better approach in general.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I don't think there's enough information in these two sentences for anybody to help.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Again, I ask for a small example of your data, and the desired output. (And put it in a reply at the bottom of this thread instead of at the top of the thread).&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2019 16:26:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Max-Min-of-character-column-with-proc-means/m-p/539682#M148744</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-03-01T16:26:14Z</dc:date>
    </item>
    <item>
      <title>Re: Max/Min of character column with proc means</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Max-Min-of-character-column-with-proc-means/m-p/539684#M148745</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/238489"&gt;@tfarkas&lt;/a&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"&lt;SPAN&gt;How can I get the maximum of a character field using proc means?"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The idea or the design that you are trying to flow downstream in itself is not the best in my humble opinion and I am pretty certain most people would mostly likely will advice to redesign your flow that accommodates robust approaches in SAS.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Yes, I agree proc sql works fine and so will datastep like&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;data w;
length want $1;
do char='c','b','a';
want=char&amp;lt;&amp;gt;want;
end;
run;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;However the analysis variables in sas procs doesn't quite do the collating sequence&amp;nbsp;of sorts be it EBCIDIC or ASCII.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;In any event, I am sure the pool of experts would be pleased to offer you a clean solution if you can post your requirement clearly.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2019 16:35:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Max-Min-of-character-column-with-proc-means/m-p/539684#M148745</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-03-01T16:35:41Z</dc:date>
    </item>
    <item>
      <title>Re: Max/Min of character column with proc means</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Max-Min-of-character-column-with-proc-means/m-p/539685#M148746</link>
      <description>&lt;P&gt;PROC MEANS is optimized for generating statistics on numeric variables. You can use character variables as CLASS variables with PROC MEANS.&amp;nbsp; You could use that to get counts:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=have nway;
  class term_code;
  output out=want ;
run;
data _null_;
  set want end=eof;
  if _n_=1 then put 'MIN ' term_code=;
  if eof then put 'MAX ' term_code=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you just want min and max of a character variable then PROC SQL is a good choice.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table min_max as 
select min(term_code) as min_term_code
    , max(term_code) as max_term_code
from have
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want the full distribution of values use PROC FREQ.&amp;nbsp; &amp;nbsp;Or perhaps you want PROC RANK?&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2019 16:35:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Max-Min-of-character-column-with-proc-means/m-p/539685#M148746</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-03-01T16:35:25Z</dc:date>
    </item>
  </channel>
</rss>

