<?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 proc format problems in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-format-problems/m-p/665965#M199199</link>
    <description>&lt;P&gt;I have a numerically coded variable, the frequency table is:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;value&lt;/TD&gt;&lt;TD&gt;frequency&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;33&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;22&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;TD&gt;11&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;I want to format it so that 1='YES',2='No', 9 is missing&lt;/P&gt;&lt;P&gt;do I applied a proc format:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
value myformat  1='Yes'
				2='No'
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;other='&amp;nbsp;';&lt;BR /&gt;run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;After I applied this format to my data and run the proc freq again, the frequency table becomes:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;value&lt;/TD&gt;&lt;TD&gt;frequency&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Yes&lt;/TD&gt;&lt;TD&gt;33&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;No&lt;/TD&gt;&lt;TD&gt;22&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;11&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;it counts the '&amp;nbsp; ' as an independent category, not missing value&lt;/P&gt;&lt;P&gt;However, what I want is :&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;value&lt;/TD&gt;&lt;TD&gt;frequency&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;yes&lt;/TD&gt;&lt;TD&gt;33&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;TD&gt;22&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;frequency missing:11&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;DIV class="branch"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="branch"&gt;&lt;DIV align="center"&gt;&lt;P class="lia-align-left"&gt;Is there a way to do that by only using format, instead of editing original data? Thanks!!!!&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Tue, 30 Jun 2020 01:21:07 GMT</pubDate>
    <dc:creator>clover</dc:creator>
    <dc:date>2020-06-30T01:21:07Z</dc:date>
    <item>
      <title>proc format problems</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-format-problems/m-p/665965#M199199</link>
      <description>&lt;P&gt;I have a numerically coded variable, the frequency table is:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;value&lt;/TD&gt;&lt;TD&gt;frequency&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;33&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;22&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;TD&gt;11&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;I want to format it so that 1='YES',2='No', 9 is missing&lt;/P&gt;&lt;P&gt;do I applied a proc format:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
value myformat  1='Yes'
				2='No'
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;other='&amp;nbsp;';&lt;BR /&gt;run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;After I applied this format to my data and run the proc freq again, the frequency table becomes:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;value&lt;/TD&gt;&lt;TD&gt;frequency&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Yes&lt;/TD&gt;&lt;TD&gt;33&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;No&lt;/TD&gt;&lt;TD&gt;22&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;11&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;it counts the '&amp;nbsp; ' as an independent category, not missing value&lt;/P&gt;&lt;P&gt;However, what I want is :&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;value&lt;/TD&gt;&lt;TD&gt;frequency&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;yes&lt;/TD&gt;&lt;TD&gt;33&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;TD&gt;22&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;frequency missing:11&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;DIV class="branch"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="branch"&gt;&lt;DIV align="center"&gt;&lt;P class="lia-align-left"&gt;Is there a way to do that by only using format, instead of editing original data? Thanks!!!!&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 30 Jun 2020 01:21:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-format-problems/m-p/665965#M199199</guid>
      <dc:creator>clover</dc:creator>
      <dc:date>2020-06-30T01:21:07Z</dc:date>
    </item>
    <item>
      <title>Re: proc format problems</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-format-problems/m-p/665975#M199204</link>
      <description>&lt;P&gt;Works for me. What are you doing differently?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  do value=1,2,9,.;
    output;
  end;
  stop;
run;

proc format;
  value myformat  
    1='Yes'
    2='No'
    other=' ';
run;

proc freq data=have ;
  table value;
  format value myformat.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1593484211475.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/46783i5559EE0490162055/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1593484211475.png" alt="Patrick_0-1593484211475.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jun 2020 06:29:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-format-problems/m-p/665975#M199204</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-06-30T06:29:28Z</dc:date>
    </item>
    <item>
      <title>Re: proc format problems</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-format-problems/m-p/666012#M199219</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Works for me. What are you doing differently?&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Since the OP is not showing all of his code I suspect he is doing something more like:&lt;/P&gt;
&lt;PRE&gt;data have;
   input value frequency;
datalines;
1	33
2	22
9	11
;

proc format;
  value myformat  
    1='Yes'
    2='No'
    other=' ';
run;

proc print data=have ;
  format value myformat.;
run;
&lt;/PRE&gt;
&lt;P&gt;Which yields:&lt;/P&gt;
&lt;PRE&gt;                                    Obs    value    frequency

                                     1      Yes         33
                                     2      No          22
                                     3                  11

&lt;/PRE&gt;
&lt;P&gt;So for &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/320408"&gt;@clover&lt;/a&gt; , you may have to go back a step earlier and use the format when creating the frequencies not after. However you may end up having to "edit the data", often referred to as recode values into new variables with the 1,2 and missing values for other operations for more consistent results.&lt;/P&gt;
&lt;P&gt;Or show more of your code.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jun 2020 09:03:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-format-problems/m-p/666012#M199219</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-30T09:03:21Z</dc:date>
    </item>
    <item>
      <title>Re: proc format problems</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-format-problems/m-p/666169#M199271</link>
      <description>&lt;P&gt;Hi Patrick,&lt;/P&gt;&lt;P&gt;I am doing the same thing as you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried different examples and find out that:&lt;/P&gt;&lt;P&gt;if the original data has a missing value, as the example you gave(1,2,9, and&lt;STRONG&gt; .&lt;/STRONG&gt;), then there would be no problem, '9' will be given to missing.&lt;/P&gt;&lt;P&gt;if the original data doesn't have missing value, as the example I gave (1,2, and 9), then '9' will be given to '&amp;nbsp; ' in the frequency table.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jun 2020 17:53:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-format-problems/m-p/666169#M199271</guid>
      <dc:creator>clover</dc:creator>
      <dc:date>2020-06-30T17:53:34Z</dc:date>
    </item>
    <item>
      <title>Re: proc format problems</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-format-problems/m-p/666171#M199273</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884" target="_blank" rel="noopener"&gt;ballardw&lt;/A&gt;, thanks for your reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, I formatted the data before I run frequency, and get the same frequency table as yours.&lt;/P&gt;&lt;P&gt;However, what I want is the table Patrick got, indicating 9 as missing, not '&amp;nbsp; ' in the frequency table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If there is no way doing that in format, I will just re-code the data.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jun 2020 17:58:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-format-problems/m-p/666171#M199273</guid>
      <dc:creator>clover</dc:creator>
      <dc:date>2020-06-30T17:58:13Z</dc:date>
    </item>
    <item>
      <title>Re: proc format problems</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-format-problems/m-p/666223#M199302</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/320408"&gt;@clover&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi Patrick,&lt;/P&gt;
&lt;P&gt;I am doing the same thing as you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried different examples and find out that:&lt;/P&gt;
&lt;P&gt;if the original data has a missing value, as the example you gave(1,2,9, and&lt;STRONG&gt; .&lt;/STRONG&gt;), then there would be no problem, '9' will be given to missing.&lt;/P&gt;
&lt;P&gt;if the original data doesn't have missing value, as the example I gave (1,2, and 9), then '9' will be given to '&amp;nbsp; ' in the frequency table.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Looks like Proc Freq is first still looking at the internal values. It's - sort of - documented behaviour &lt;A href="https://go.documentation.sas.com/?docsetId=procstat&amp;amp;docsetTarget=procstat_freq_details02.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_self"&gt;here&lt;/A&gt;. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;I guess you will have to create a new variable - newvar=put(var,myformat.); - for use in Proc Format to get what you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;When you use PROC FORMAT to create a user-written format that combines missing and nonmissing values into one category, PROC FREQ treats the entire category of formatted values as missing. For example, a questionnaire codes 1 as yes, 2 as no, and 8 as a no answer. The following PROC FORMAT statements create a user-written format:&lt;/P&gt;
&lt;PRE class="xisDoc-code"&gt;proc format;
   value Questfmt 1   ='Yes'
                  2   ='No'
                  8,. ='Missing';
run;
&lt;/PRE&gt;
&lt;P&gt;When you use a FORMAT statement to assign&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE class="aa-varname"&gt;Questfmt.&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to a variable, the variable’s frequency table no longer includes a frequency count for the response of 8. You must use the MISSING or MISSPRINT option in the TABLES statement to list the frequency for no answer. The frequency count for this level includes observations with either a value of 8 or a missing value (.).&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jun 2020 22:16:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-format-problems/m-p/666223#M199302</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-06-30T22:16:17Z</dc:date>
    </item>
  </channel>
</rss>

