<?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 freq with format to re-order output in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-freq-with-format-to-re-order-output/m-p/301828#M63937</link>
    <description>&lt;P&gt;I can't replicate your issue. You have something wrong somewhere else.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Check your raw values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC FORMAT ;
   VALUE $ trtfmt
        'A'='7.5 mg/26-37Kg  ' 
        'B'='10.0 mg/38-50Kg '
        'C'='12.5 mg/51-62Kg ' 
		'D'='15.0 mg/63-75Kg '
		'E'='17.5 mg/76-87Kg '
		'F'='20.0 mg/88-111Kg';
RUN;

data test;
str='ABCDEF';
do i=1 to 30;
x=floor(rand('uniform')*6)+1;
y=char(str, x);
output;
end;
run;

proc freq data=test;
table y;
format y $trtfmt.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 30 Sep 2016 20:21:34 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2016-09-30T20:21:34Z</dc:date>
    <item>
      <title>proc freq with format to re-order output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-freq-with-format-to-re-order-output/m-p/301821#M63936</link>
      <description>&lt;P&gt;I want to list the output with 7.5 dose as the first one, but using the following code I still got 7.5 dose as the last one. What is wrong here?&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC FORMAT ;
   VALUE $ trtfmt
        'A'='7.5 mg/26-37Kg  ' 
        'B'='10.0 mg/38-50Kg '
        'C'='12.5 mg/51-62Kg ' 
		'D'='15.0 mg/63-75Kg '
		'E'='17.5 mg/76-87Kg '
		'F'='20.0 mg/88-111Kg';
RUN;

proc freq data=mydata ORDER=FORMATTED;
tables trtcat1 * AGEGRP /nocol ;
format trtcat1 $trtfmt.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Sep 2016 20:05:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-freq-with-format-to-re-order-output/m-p/301821#M63936</guid>
      <dc:creator>fengyuwuzu</dc:creator>
      <dc:date>2016-09-30T20:05:13Z</dc:date>
    </item>
    <item>
      <title>Re: proc freq with format to re-order output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-freq-with-format-to-re-order-output/m-p/301828#M63937</link>
      <description>&lt;P&gt;I can't replicate your issue. You have something wrong somewhere else.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Check your raw values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC FORMAT ;
   VALUE $ trtfmt
        'A'='7.5 mg/26-37Kg  ' 
        'B'='10.0 mg/38-50Kg '
        'C'='12.5 mg/51-62Kg ' 
		'D'='15.0 mg/63-75Kg '
		'E'='17.5 mg/76-87Kg '
		'F'='20.0 mg/88-111Kg';
RUN;

data test;
str='ABCDEF';
do i=1 to 30;
x=floor(rand('uniform')*6)+1;
y=char(str, x);
output;
end;
run;

proc freq data=test;
table y;
format y $trtfmt.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 30 Sep 2016 20:21:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-freq-with-format-to-re-order-output/m-p/301828#M63937</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-09-30T20:21:34Z</dc:date>
    </item>
    <item>
      <title>Re: proc freq with format to re-order output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-freq-with-format-to-re-order-output/m-p/301829#M63938</link>
      <description>&lt;P&gt;You have two options, remove the Order=Formatted and let the internal order work or&lt;/P&gt;
&lt;P&gt;Change&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#800080" face="SAS Monospace" size="2"&gt;'A'&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;=&lt;/FONT&gt;&lt;FONT color="#800080" face="SAS Monospace" size="2"&gt;'7.5 mg/26-37Kg '&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#800080" face="SAS Monospace" size="2"&gt;to &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#800080" face="SAS Monospace" size="2"&gt;'A'&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;=&lt;/FONT&gt;&lt;FONT color="#800080" face="SAS Monospace" size="2"&gt;' 7.5 mg/26-37Kg'&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#800080" face="SAS Monospace" size="2"&gt;the leading space will become part of the value and spaces sort befor digits.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Sep 2016 20:28:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-freq-with-format-to-re-order-output/m-p/301829#M63938</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-09-30T20:28:45Z</dc:date>
    </item>
    <item>
      <title>Re: proc freq with format to re-order output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-freq-with-format-to-re-order-output/m-p/303403#M64439</link>
      <description>&lt;P&gt;I used your code, which works. But in the output it is the "A"...."D" that are listed in order,&lt;/P&gt;
&lt;P&gt;not the actual doses.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/5213i5CE4CCAFCC797AF8/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="Capture1.PNG" title="Capture1.PNG" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a way to replace the "A" to "D" with the actual doses? Thanks&lt;/P&gt;</description>
      <pubDate>Sun, 09 Oct 2016 00:51:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-freq-with-format-to-re-order-output/m-p/303403#M64439</guid>
      <dc:creator>fengyuwuzu</dc:creator>
      <dc:date>2016-10-09T00:51:52Z</dc:date>
    </item>
    <item>
      <title>Re: proc freq with format to re-order output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-freq-with-format-to-re-order-output/m-p/303405#M64440</link>
      <description>&lt;P&gt;No it doesn't.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The output is below. Review your code and run my exact code. Then look for the differences.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV id="IDX" class="proc_title_group"&gt;
&lt;P class="c proctitle"&gt;The FREQ Procedure&lt;/P&gt;
&lt;/DIV&gt;
&lt;SECTION&gt;
&lt;ARTICLE&gt;
&lt;TABLE class="table"&gt;&lt;COLGROUP&gt;&lt;COL /&gt;&lt;/COLGROUP&gt;&lt;COLGROUP&gt;&lt;COL /&gt;&lt;COL /&gt;&lt;COL /&gt;&lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="b header" scope="col"&gt;y&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;Frequency&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;Percent&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;Cumulative&lt;BR /&gt;Frequency&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;Cumulative&lt;BR /&gt;Percent&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="rowheader" scope="row"&gt;7.5 mg/26-37Kg&lt;/TH&gt;
&lt;TD class="r data"&gt;10&lt;/TD&gt;
&lt;TD class="r data"&gt;33.33&lt;/TD&gt;
&lt;TD class="r data"&gt;10&lt;/TD&gt;
&lt;TD class="r data"&gt;33.33&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="rowheader" scope="row"&gt;10.0 mg/38-50Kg&lt;/TH&gt;
&lt;TD class="r data"&gt;3&lt;/TD&gt;
&lt;TD class="r data"&gt;10.00&lt;/TD&gt;
&lt;TD class="r data"&gt;13&lt;/TD&gt;
&lt;TD class="r data"&gt;43.33&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="rowheader" scope="row"&gt;12.5 mg/51-62Kg&lt;/TH&gt;
&lt;TD class="r data"&gt;6&lt;/TD&gt;
&lt;TD class="r data"&gt;20.00&lt;/TD&gt;
&lt;TD class="r data"&gt;19&lt;/TD&gt;
&lt;TD class="r data"&gt;63.33&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="rowheader" scope="row"&gt;15.0 mg/63-75Kg&lt;/TH&gt;
&lt;TD class="r data"&gt;4&lt;/TD&gt;
&lt;TD class="r data"&gt;13.33&lt;/TD&gt;
&lt;TD class="r data"&gt;23&lt;/TD&gt;
&lt;TD class="r data"&gt;76.67&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="rowheader" scope="row"&gt;17.5 mg/76-87Kg&lt;/TH&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;6.67&lt;/TD&gt;
&lt;TD class="r data"&gt;25&lt;/TD&gt;
&lt;TD class="r data"&gt;83.33&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="rowheader" scope="row"&gt;20.0 mg/88-111Kg&lt;/TH&gt;
&lt;TD class="r data"&gt;5&lt;/TD&gt;
&lt;TD class="r data"&gt;16.67&lt;/TD&gt;
&lt;TD class="r data"&gt;30&lt;/TD&gt;
&lt;TD class="r data"&gt;100.00&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/ARTICLE&gt;
&lt;/SECTION&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Oct 2016 01:22:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-freq-with-format-to-re-order-output/m-p/303405#M64440</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-10-09T01:22:29Z</dc:date>
    </item>
    <item>
      <title>Re: proc freq with format to re-order output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-freq-with-format-to-re-order-output/m-p/303406#M64441</link>
      <description>Right. You are right &lt;BR /&gt;I did not run the format correctly.</description>
      <pubDate>Sun, 09 Oct 2016 01:38:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-freq-with-format-to-re-order-output/m-p/303406#M64441</guid>
      <dc:creator>fengyuwuzu</dc:creator>
      <dc:date>2016-10-09T01:38:27Z</dc:date>
    </item>
    <item>
      <title>Re: proc freq with format to re-order output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-freq-with-format-to-re-order-output/m-p/303408#M64442</link>
      <description>&lt;P&gt;Hi Reeza&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have another question.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;in your code, the values of Y&amp;nbsp;are "A", ... "F".&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In my data, the values of the doses are "&lt;SPAN&gt;7.5 mg/26-37Kg", etc.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;So, do I&amp;nbsp;have to first convert my data to a format with Doses values of "A", "B", ... "F" to use this format to control output order?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Oct 2016 02:49:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-freq-with-format-to-re-order-output/m-p/303408#M64442</guid>
      <dc:creator>fengyuwuzu</dc:creator>
      <dc:date>2016-10-09T02:49:37Z</dc:date>
    </item>
    <item>
      <title>Re: proc freq with format to re-order output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-freq-with-format-to-re-order-output/m-p/303415#M64443</link>
      <description>&lt;P&gt;I have no idea you mean, based on your initial question this was how your data is structured. If it's not you need to clearly state how it is structured. New question with sample input data that accurately reflects your problem.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Oct 2016 03:11:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-freq-with-format-to-re-order-output/m-p/303415#M64443</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-10-09T03:11:58Z</dc:date>
    </item>
  </channel>
</rss>

