<?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: Finding number of special missing in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Finding-number-of-special-missing/m-p/861614#M340339</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input q1 q2;
datalines;
0 999
1 .
3 0
777 1
0 2
2 3
3 2
777 1
;
run;

proc format;
    value $ missfmt ' '="Missing" other="Not Missing";
    value nmissfmt .="Missing" 777,999 = [8.] other="Not Missing";
run;



*Proc freq to count missing/non missing;
ods select none;
*turns off the output so the results do not get too messy;
ods table onewayfreqs=temp;

proc freq data=have;
    table _all_ / missing;
    format _numeric_ nmissfmt. _character_ $missfmt.;
run;

ods select all;
*Format output;

data long;
    length variable $32. variable_value $50.;
    set temp;
    Variable=scan(table, 2);
    Variable_Value=strip(trim(vvaluex(variable)));
    presentation=catt(frequency, " (", trim(put(percent/100, percent7.1)), ")");
    keep variable variable_value frequency percent cum: presentation;
    label variable='Variable' variable_value='Variable Value';
run;

data long;
    length variable $32. variable_value $50.;
    set temp;
    Variable=scan(table, 2);
    Variable_Value=strip(trim(vvaluex(variable)));
    presentation=catt(frequency, " (", trim(put(percent/100, percent7.1)), ")");
    keep variable variable_value frequency percent cum: presentation;
    label variable='Variable' variable_value='Variable Value';
run;

proc sort data=long;
    by variable;
run;



*transpose only N;

proc transpose data=long (where=(variable_value in ('777', '999'))) out=wide_N prefix=N_;
    by variable;
    id variable_value;
    var frequency;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Derived from this code here:&amp;nbsp;&lt;A href="https://gist.github.com/statgeek/2de1faf1644dc8160fe721056202f111" target="_blank"&gt;https://gist.github.com/statgeek/2de1faf1644dc8160fe721056202f111&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Gets you pretty close, but no 0's. I'm assuming you can figure out how to add those.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/440200"&gt;@gloverb1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for the quick response. Given the data below, is there a way to get an output formatted such:&amp;nbsp;&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;777 | 999&lt;/P&gt;
&lt;P&gt;Q1&amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp;|&amp;nbsp; &amp;nbsp;0&lt;/P&gt;
&lt;P&gt;Q2&amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp;|&amp;nbsp; &amp;nbsp;1&lt;/P&gt;
&lt;P&gt;My end goal is to be able to identify any outlying number of 777 or 999 responses for a given variable.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;data have;
input q1 q2;
datalines;
0 999
1 .
3 0
777 1
0 2
2 3
3 2
777 1
;&lt;BR /&gt;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 28 Feb 2023 22:38:27 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2023-02-28T22:38:27Z</dc:date>
    <item>
      <title>Finding number of special missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-number-of-special-missing/m-p/861596#M340335</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a survey dataset with ~400 variables that I want to be able to find the number of special missing for each variable. I want the number of missing but need to differentiate between responses 777 (I don't know) and 999 (I prefer not to answer). Is there a quick way, similar to proc means nmiss, that will output how many of each special missing are in each variable?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Brian&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2023 21:20:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-number-of-special-missing/m-p/861596#M340335</guid>
      <dc:creator>gloverb1</dc:creator>
      <dc:date>2023-02-28T21:20:53Z</dc:date>
    </item>
    <item>
      <title>Re: Finding number of special missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-number-of-special-missing/m-p/861597#M340336</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
    value $ missfmt ' '="Missing" other="Not Missing";
    value nmissfmt .="Missing" 777 = "I don't know" 999 = "I Prefer not to answer" other="Not Missing";
run;

*Proc freq to count missing/non missing;
ods select none;
*turns off the output so the results do not get too messy;
ods table onewayfreqs=temp;

proc freq data=&amp;amp;INPUT_DSN.;
    table _all_ / missing;
    format _numeric_ nmissfmt. _character_ $missfmt.;
run;

ods select all;
*Format output;

data long;
    length variable $32. variable_value $50.;
    set temp;
    Variable=scan(table, 2);
    Variable_Value=strip(trim(vvaluex(variable)));
    presentation=catt(frequency, " (", trim(put(percent/100, percent7.1)), ")");
    keep variable variable_value frequency percent cum: presentation;
    label variable='Variable' variable_value='Variable Value';
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Something like above should get you started for numeric variables. If you can post sample data that always helps get working, tested code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/440200"&gt;@gloverb1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a survey dataset with ~400 variables that I want to be able to find the number of special missing for each variable. I want the number of missing but need to differentiate between responses 777 (I don't know) and 999 (I prefer not to answer). Is there a quick way, similar to proc means nmiss, that will output how many of each special missing are in each variable?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Brian&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2023 21:27:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-number-of-special-missing/m-p/861597#M340336</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-02-28T21:27:18Z</dc:date>
    </item>
    <item>
      <title>Re: Finding number of special missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-number-of-special-missing/m-p/861600#M340338</link>
      <description>&lt;P&gt;Thanks for the quick response. Given the data below, is there a way to get an output formatted such:&amp;nbsp;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;777 | 999&lt;/P&gt;&lt;P&gt;Q1&amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp;|&amp;nbsp; &amp;nbsp;0&lt;/P&gt;&lt;P&gt;Q2&amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp;|&amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;My end goal is to be able to identify any outlying number of 777 or 999 responses for a given variable.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data have;
input q1 q2;
datalines;
0 999
1 .
3 0
777 1
0 2
2 3
3 2
777 1
;&lt;BR /&gt;run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2023 21:50:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-number-of-special-missing/m-p/861600#M340338</guid>
      <dc:creator>gloverb1</dc:creator>
      <dc:date>2023-02-28T21:50:57Z</dc:date>
    </item>
    <item>
      <title>Re: Finding number of special missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-number-of-special-missing/m-p/861614#M340339</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input q1 q2;
datalines;
0 999
1 .
3 0
777 1
0 2
2 3
3 2
777 1
;
run;

proc format;
    value $ missfmt ' '="Missing" other="Not Missing";
    value nmissfmt .="Missing" 777,999 = [8.] other="Not Missing";
run;



*Proc freq to count missing/non missing;
ods select none;
*turns off the output so the results do not get too messy;
ods table onewayfreqs=temp;

proc freq data=have;
    table _all_ / missing;
    format _numeric_ nmissfmt. _character_ $missfmt.;
run;

ods select all;
*Format output;

data long;
    length variable $32. variable_value $50.;
    set temp;
    Variable=scan(table, 2);
    Variable_Value=strip(trim(vvaluex(variable)));
    presentation=catt(frequency, " (", trim(put(percent/100, percent7.1)), ")");
    keep variable variable_value frequency percent cum: presentation;
    label variable='Variable' variable_value='Variable Value';
run;

data long;
    length variable $32. variable_value $50.;
    set temp;
    Variable=scan(table, 2);
    Variable_Value=strip(trim(vvaluex(variable)));
    presentation=catt(frequency, " (", trim(put(percent/100, percent7.1)), ")");
    keep variable variable_value frequency percent cum: presentation;
    label variable='Variable' variable_value='Variable Value';
run;

proc sort data=long;
    by variable;
run;



*transpose only N;

proc transpose data=long (where=(variable_value in ('777', '999'))) out=wide_N prefix=N_;
    by variable;
    id variable_value;
    var frequency;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Derived from this code here:&amp;nbsp;&lt;A href="https://gist.github.com/statgeek/2de1faf1644dc8160fe721056202f111" target="_blank"&gt;https://gist.github.com/statgeek/2de1faf1644dc8160fe721056202f111&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Gets you pretty close, but no 0's. I'm assuming you can figure out how to add those.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/440200"&gt;@gloverb1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for the quick response. Given the data below, is there a way to get an output formatted such:&amp;nbsp;&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;777 | 999&lt;/P&gt;
&lt;P&gt;Q1&amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp;|&amp;nbsp; &amp;nbsp;0&lt;/P&gt;
&lt;P&gt;Q2&amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp;|&amp;nbsp; &amp;nbsp;1&lt;/P&gt;
&lt;P&gt;My end goal is to be able to identify any outlying number of 777 or 999 responses for a given variable.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;data have;
input q1 q2;
datalines;
0 999
1 .
3 0
777 1
0 2
2 3
3 2
777 1
;&lt;BR /&gt;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2023 22:38:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-number-of-special-missing/m-p/861614#M340339</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-02-28T22:38:27Z</dc:date>
    </item>
  </channel>
</rss>

