<?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: How does SAS classified these as missing value? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-does-SAS-classified-these-as-missing-value/m-p/846577#M334659</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/431484"&gt;@Nietzsche&lt;/a&gt;&amp;nbsp;I agree with you that the result is not immediately intuitive. However if you give it a bit of thought then when grouping multiple values into a single category and this category includes missings then Proc Freq needs to "decide" if it needs to treat the category as missing or as non-missing to only count the rows belonging to the same category in a single place.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The SAS documentation &lt;A href="https://documentation.sas.com/doc/en/statcdc/14.2/statug/statug_freq_details02.htm" target="_self"&gt;here&lt;/A&gt; is clear about this:&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1669637080612.png" style="width: 1040px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/77769i41E222E53FEB4AA3/image-dimensions/1040x26?v=v2" width="1040" height="26" role="button" title="Patrick_0-1669637080612.png" alt="Patrick_0-1669637080612.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;You can use the "missing" keyword to include the category in the analysis OR you need to define a format that puts missings in it's own category.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
	value $answerA
	'0'='No'
	'1'='Yes'
	other='Did not answer'
  ;
	value $answerB
	'0'='No'
	'1'='Yes'
  ' ' = 'Missing'
	other='Did not answer'
  ;
run;

data Taxes;
	informat SSN $11. Gender $1. Question_1 - Question_4 $1.;
	input SSN Gender Question_1 - Question_5;
datalines;
101-23-1928 M 1 3 C 4 23000
919-67-7800 F 9 2 D 2 17000
202-22-3848 M 0 5 A 5 57000
344-87-8737 M 1 1 B 2 34123
444-38-2837 F . 4 A 1 17233
763-01-0123 F 0 4 A 4 .
;

title 'Frequencies for the Taxes Data Set';
proc freq data=taxes;
	format Question_1 $answerA.;
	tables Question_1 /missing;
run;
proc freq data=taxes;
	format Question_1 $answerB.;
	tables Question_1;
run;
title;&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-1669637512071.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/77773iDE4B7E6328BD1668/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1669637512071.png" alt="Patrick_0-1669637512071.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 28 Nov 2022 19:20:54 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2022-11-28T19:20:54Z</dc:date>
    <item>
      <title>How does SAS classified these as missing value?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-does-SAS-classified-these-as-missing-value/m-p/846484#M334625</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I ran the following program&lt;/P&gt;
&lt;PRE&gt;proc format lib=formtlib;
	value $answer
	'0'='No'
	'1'='Yes'
	other='Did not answer';

data cody.Taxes;
	informat SSN $11. Gender $1. Question_1 - Question_4 $1.;
	input SSN Gender Question_1 - Question_5;

datalines;
101-23-1928 M 1 3 C 4 23000
919-67-7800 F 9 2 D 2 17000
202-22-3848 M 0 5 A 5 57000
344-87-8737 M 1 1 B 2 34123
444-38-2837 F . 4 A 1 17233
763-01-0123 F 0 4 A 4 .
;

title 'Frequencies for the Taxes Data Set';

proc freq data=cody.taxes;
	format Question_1 $answer.;
	tables Question_1;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So from the datalines, you can see that the six observations to question 1 is 1, 9, 0, 1, . , 0.&lt;/P&gt;
&lt;P&gt;So I have two "1", two "0", one "9" and one "."&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the freq print out is&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Nietzsche_0-1669543756304.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/77751iACE1A5985F4C8800/image-size/large?v=v2&amp;amp;px=999" role="button" title="Nietzsche_0-1669543756304.png" alt="Nietzsche_0-1669543756304.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;and since I have defined my format as&lt;/P&gt;
&lt;PRE&gt;proc format lib=formtlib;
	value $answer
	'0'='No'
	'1'='Yes'
	other='Did not answer';&lt;/PRE&gt;
&lt;P&gt;so I don't understand is that why are both the "9" and "." classified as missing value and not as "other" ?&lt;/P&gt;
&lt;P&gt;"9" is pretty obvious should be other right? It is not "0" or "1" and it is not missing.&lt;/P&gt;
&lt;P&gt;"." is also not missing because in the informat, I specified it to be character value, so it should be not missing since only " " is considered missing for character variable.&lt;/P&gt;</description>
      <pubDate>Sun, 27 Nov 2022 10:14:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-does-SAS-classified-these-as-missing-value/m-p/846484#M334625</guid>
      <dc:creator>Nietzsche</dc:creator>
      <dc:date>2022-11-27T10:14:04Z</dc:date>
    </item>
    <item>
      <title>Re: How does SAS classified these as missing value?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-does-SAS-classified-these-as-missing-value/m-p/846499#M334626</link>
      <description>&lt;P&gt;When SAS has to combine two (or more) formatted values into a category for the purpose of reporting, it picks the first value alphabetically (if a character variable) or numerically (if a numeric variable) to represent the category. So, in this case, when the values in the category are a missing and a '9', it uses the missing (as this is first alphabetically), and PROC FREQ by default will not consider a missing as a valid value to create a category from. If you use the MISSING option in the TABLES statement of PROC FREQ, this overrides the default behavior of handling missings, and then you get the expected output.&lt;/P&gt;</description>
      <pubDate>Sun, 27 Nov 2022 12:07:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-does-SAS-classified-these-as-missing-value/m-p/846499#M334626</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-11-27T12:07:06Z</dc:date>
    </item>
    <item>
      <title>Re: How does SAS classified these as missing value?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-does-SAS-classified-these-as-missing-value/m-p/846525#M334632</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;explained the main issue.&amp;nbsp; But just to add a bit, note that this statement:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/431484"&gt;@Nietzsche&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;"." is also not missing because in the informat, I specified it to be character value, so it should be not missing since only " " is considered missing for character variable.&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;is wrong.&amp;nbsp; If you PROC PRINT the data, you will see that the value of Question_1 for the fifth record is ' ', not '.'&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is because the $1 informat you used to read in the data will interpret as a period as a missing value, as documented:&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/leforinforref/n1v0ez0x2x99qdn15797taed37ji.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/leforinforref/n1v0ez0x2x99qdn15797taed37ji.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As mentioned in the end of the documentation, if you want a period to be read into a character variable as a period, you could change to use the $char1 informat.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 00:08:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-does-SAS-classified-these-as-missing-value/m-p/846525#M334632</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-11-28T00:08:22Z</dc:date>
    </item>
    <item>
      <title>Re: How does SAS classified these as missing value?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-does-SAS-classified-these-as-missing-value/m-p/846569#M334655</link>
      <description>&lt;P&gt;I read this paraphrase multiple times, I still do not understand it. Can someone explain this to me in layman's term?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 11:19:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-does-SAS-classified-these-as-missing-value/m-p/846569#M334655</guid>
      <dc:creator>Nietzsche</dc:creator>
      <dc:date>2022-11-28T11:19:26Z</dc:date>
    </item>
    <item>
      <title>Re: How does SAS classified these as missing value?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-does-SAS-classified-these-as-missing-value/m-p/846577#M334659</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/431484"&gt;@Nietzsche&lt;/a&gt;&amp;nbsp;I agree with you that the result is not immediately intuitive. However if you give it a bit of thought then when grouping multiple values into a single category and this category includes missings then Proc Freq needs to "decide" if it needs to treat the category as missing or as non-missing to only count the rows belonging to the same category in a single place.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The SAS documentation &lt;A href="https://documentation.sas.com/doc/en/statcdc/14.2/statug/statug_freq_details02.htm" target="_self"&gt;here&lt;/A&gt; is clear about this:&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1669637080612.png" style="width: 1040px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/77769i41E222E53FEB4AA3/image-dimensions/1040x26?v=v2" width="1040" height="26" role="button" title="Patrick_0-1669637080612.png" alt="Patrick_0-1669637080612.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;You can use the "missing" keyword to include the category in the analysis OR you need to define a format that puts missings in it's own category.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
	value $answerA
	'0'='No'
	'1'='Yes'
	other='Did not answer'
  ;
	value $answerB
	'0'='No'
	'1'='Yes'
  ' ' = 'Missing'
	other='Did not answer'
  ;
run;

data Taxes;
	informat SSN $11. Gender $1. Question_1 - Question_4 $1.;
	input SSN Gender Question_1 - Question_5;
datalines;
101-23-1928 M 1 3 C 4 23000
919-67-7800 F 9 2 D 2 17000
202-22-3848 M 0 5 A 5 57000
344-87-8737 M 1 1 B 2 34123
444-38-2837 F . 4 A 1 17233
763-01-0123 F 0 4 A 4 .
;

title 'Frequencies for the Taxes Data Set';
proc freq data=taxes;
	format Question_1 $answerA.;
	tables Question_1 /missing;
run;
proc freq data=taxes;
	format Question_1 $answerB.;
	tables Question_1;
run;
title;&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-1669637512071.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/77773iDE4B7E6328BD1668/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1669637512071.png" alt="Patrick_0-1669637512071.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 19:20:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-does-SAS-classified-these-as-missing-value/m-p/846577#M334659</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-11-28T19:20:54Z</dc:date>
    </item>
    <item>
      <title>Re: How does SAS classified these as missing value?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-does-SAS-classified-these-as-missing-value/m-p/846593#M334662</link>
      <description>&lt;P&gt;Modify your PROC FREQ code like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=cody.taxes;
	format Question_1 $answer.;
	tables Question_1/out=a;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next, look at data set A. Then look at data set A where you have removed the format from variable QUESTION_1, you will see that the category assigned to the 9 and missing is listed as missing, despite the fact that some of the values have a non-missing value of 9. By default PROC FREQ does not tabulate frequencies for the missing level.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Re-run the code using the MISSING option, then see what happens.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 12:44:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-does-SAS-classified-these-as-missing-value/m-p/846593#M334662</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-11-28T12:44:37Z</dc:date>
    </item>
  </channel>
</rss>

