<?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-order by format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-freq-order-by-format/m-p/524326#M142579</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Perfect and thank you.&lt;/P&gt;
&lt;P&gt;Can you please explain Why the sort is not working well? I want that categories will appear in same order as they appear in proc format.(&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;frequencies&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;in&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;order&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;as determined by the&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;formatted&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;value)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Joe&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Similar to your other question on formatted order: Proc Freq uses the Formatted VALUE, not the order of appearance in a format definition to order the output.&lt;/P&gt;
&lt;P&gt;So in these format definitions:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
value $Fm1t ( notsorted)
'Male'='M'
'Female'='F';  F is before M 
Run;

proc format;
value $Fm2t ( notsorted)
'Desirable'='Desirable'
'Borderline'='Borderline' Borderline is before Desirable
'High'='High';
Run;

proc format;
value $Fm3t ( notsorted)
'Underweight'='Underweight'
'Normal'='Normal weight'  Normal is before Underweight
'Overweight'='Overweight';
Run&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 03 Jan 2019 17:26:43 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2019-01-03T17:26:43Z</dc:date>
    <item>
      <title>Proc freq-order by format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-freq-order-by-format/m-p/524050#M142464</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I &amp;nbsp;want to perform multiple proc freq using Macro.&lt;/P&gt;
&lt;P&gt;I want that in each explanatory variable the categories will be by formatted order.&lt;/P&gt;
&lt;P&gt;When I run the following code I get an error.&lt;/P&gt;
&lt;P&gt;I will be happy to learn what is wrong with this code and to see the correct code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
value $Fm1t ( notsorted)
'Male'='M'
'Female'='F';
Run;

proc format;
value $Fm2t ( notsorted)
'Desirable'='Desirable'
'Borderline'='Borderline'
'High'='High';
Run;

proc format;
value $Fm3t ( notsorted)
'Underweight'='Underweight'
'Normal'='Normal weight'
'Overweight'='Overweight';
Run;

proc format;
value $Fm4t ( notsorted)
'Non-smoker'='Non-smoker'
'Light (1-5)'='Light Smoker (1-5)'
'Moderate (6-15)'='Moderate Smoker(6-15)'
'Heavy (16-25)'='Heavy Smoker(16-25)'
'Very Heavy (&amp;gt; 25)'='Very Heavy Smoker(&amp;gt; 25)';
Run;

proc format;
value $Fm5t ( notsorted)
'Optimal'='Optimal Blood Pressure'
'Normal'='Normal Blood Pressure'
'High'='High Blood Pressure';
Run;

Data heart;
set sashelp.heart;
Format sex $Fm1t.
Chol_Status $Fm2t.
Weight_Status $Fm3t.
Smoking_Status $Fm4t.
BP_Status $Fm5t.;
Run;



%macro mmacro1(pred,i); 
proc freq data=heart order=formatted;  
tables &amp;amp;pred*Status/chisq sparse outpct out=outfreq&amp;amp;i ;
output out=stats&amp;amp;i chisq;
format &amp;amp;pred $Fm&amp;amp;i.t;
run;
%mend;

%mmacro1(sex,1);
%mmacro1(Chol_Status,2);
%mmacro1(Weight_Status,3);
%mmacro1(Smoking_Status,4);
%mmacro1(BP_Status,5);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jan 2019 11:02:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-freq-order-by-format/m-p/524050#M142464</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2019-01-02T11:02:02Z</dc:date>
    </item>
    <item>
      <title>Re: Proc freq-order by format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-freq-order-by-format/m-p/524057#M142468</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;When I run the following code I get an error.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What error? Show us the full SASLOG.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jan 2019 11:50:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-freq-order-by-format/m-p/524057#M142468</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-01-02T11:50:58Z</dc:date>
    </item>
    <item>
      <title>Re: Proc freq-order by format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-freq-order-by-format/m-p/524058#M142469</link>
      <description>&lt;P&gt;IF you run the code you will see the log.&lt;/P&gt;
&lt;P&gt;"&lt;/P&gt;
&lt;P&gt;NOTE: Line generated by the macro variable "I".&lt;BR /&gt;3840 $Fm1t&lt;BR /&gt; -&lt;BR /&gt; 22&lt;BR /&gt; 200&lt;BR /&gt;WARNING: Variable FM1T not found in data set WORK.HEART.&lt;/P&gt;
&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, a format name, ;, -, :, _ALL_, _CHARACTER_, _CHAR_, _NUMERIC_.&lt;/P&gt;
&lt;P&gt;ERROR 200-322: The symbol is not recognized and will be ignored."&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jan 2019 11:56:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-freq-order-by-format/m-p/524058#M142469</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2019-01-02T11:56:52Z</dc:date>
    </item>
    <item>
      <title>Re: Proc freq-order by format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-freq-order-by-format/m-p/524060#M142471</link>
      <description>&lt;P&gt;In the line&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;format &amp;amp;pred $Fm&amp;amp;i.t;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;you need another dot after the t:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;format &amp;amp;pred $Fm&amp;amp;i.t.;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jan 2019 12:02:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-freq-order-by-format/m-p/524060#M142471</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-01-02T12:02:01Z</dc:date>
    </item>
    <item>
      <title>Re: Proc freq-order by format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-freq-order-by-format/m-p/524061#M142472</link>
      <description>&lt;P&gt;Perfect and thank you.&lt;/P&gt;
&lt;P&gt;Can you please explain Why the sort is not working well? I want that categories will appear in same order as they appear in proc format.(&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;frequencies&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;in&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;order&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;as determined by the&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;formatted&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;value)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Joe&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jan 2019 12:52:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-freq-order-by-format/m-p/524061#M142472</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2019-01-02T12:52:32Z</dc:date>
    </item>
    <item>
      <title>Re: Proc freq-order by format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-freq-order-by-format/m-p/524326#M142579</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Perfect and thank you.&lt;/P&gt;
&lt;P&gt;Can you please explain Why the sort is not working well? I want that categories will appear in same order as they appear in proc format.(&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;frequencies&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;in&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;order&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;as determined by the&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;formatted&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;value)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Joe&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Similar to your other question on formatted order: Proc Freq uses the Formatted VALUE, not the order of appearance in a format definition to order the output.&lt;/P&gt;
&lt;P&gt;So in these format definitions:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
value $Fm1t ( notsorted)
'Male'='M'
'Female'='F';  F is before M 
Run;

proc format;
value $Fm2t ( notsorted)
'Desirable'='Desirable'
'Borderline'='Borderline' Borderline is before Desirable
'High'='High';
Run;

proc format;
value $Fm3t ( notsorted)
'Underweight'='Underweight'
'Normal'='Normal weight'  Normal is before Underweight
'Overweight'='Overweight';
Run&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jan 2019 17:26:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-freq-order-by-format/m-p/524326#M142579</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-01-03T17:26:43Z</dc:date>
    </item>
  </channel>
</rss>

