<?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: Add row in empty table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Add-row-in-empty-table/m-p/821375#M324283</link>
    <description>thanks</description>
    <pubDate>Sat, 02 Jul 2022 16:04:24 GMT</pubDate>
    <dc:creator>Toni2</dc:creator>
    <dc:date>2022-07-02T16:04:24Z</dc:date>
    <item>
      <title>Add row in empty table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-row-in-empty-table/m-p/821355#M324269</link>
      <description>&lt;P&gt;hi, i am trying to find the % of missing in a number of character variables in monthly basis&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;my problem is var2 has no missing values and creates an empty table (miss_a) which is this one with headers:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="192"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="46"&gt;month&lt;/TD&gt;
&lt;TD width="33"&gt;var2&lt;/TD&gt;
&lt;TD width="51"&gt;COUNT&lt;/TD&gt;
&lt;TD width="62"&gt;PERCENT&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want when miss_a is empty then to add in column PERCENT = 0.&amp;nbsp;However, no action to be taken if miss_a is NOT empty&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i would prefer this to be in a separate step rather than in proc freq&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data A;
input month $ var1 $ var2 $;
datalines;
1 2 5
1 . 8
1 . 7
1 5 2
2 7 0
3 3 2
3 2 9
3 . 2
4 7 4
4 . 5
5 6 2
5 2 2
5 . 3
5 2 2
5 . 4
6 8 2
6 2 2
run;

proc freq data=A;
table var2 / noprint missing out=miss_a;
WHERE var2=""; 
by month;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 02 Jul 2022 07:56:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-row-in-empty-table/m-p/821355#M324269</guid>
      <dc:creator>Toni2</dc:creator>
      <dc:date>2022-07-02T07:56:56Z</dc:date>
    </item>
    <item>
      <title>Re: Add row in empty table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-row-in-empty-table/m-p/821358#M324270</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/372747"&gt;@Toni2&lt;/a&gt;,&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/372747"&gt;@Toni2&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;hi, i am trying to find the % of missing in a number of character variables in monthly basis&lt;/P&gt;
&lt;P&gt;(...)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=A;
table var2 / noprint missing out=miss_a;
WHERE var2=""; 
by month;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;By using that WHERE condition you exclude observations with non-missing VAR2 values, but you need them to compute the percentage.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In PROC SQL the computation is very clear: For each month divide the number of observations with missing VAR&lt;EM&gt;n&lt;/EM&gt; by the number of all observations, then multiply by 100.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select month, nmiss(var1)/count(*)*100 as misspct_var1,
              nmiss(var2)/count(*)*100 as misspct_var2
from A
group by month;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;         misspct_    misspct_
month      var1        var2

  1       50.0000        0
  2        0.0000        0
  3       33.3333        0
  4       50.0000        0
  5       40.0000        0
  6        0.0000        0&lt;/PRE&gt;</description>
      <pubDate>Sat, 02 Jul 2022 08:50:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-row-in-empty-table/m-p/821358#M324270</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-07-02T08:50:51Z</dc:date>
    </item>
    <item>
      <title>Re: Add row in empty table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-row-in-empty-table/m-p/821373#M324282</link>
      <description>&lt;P&gt;you may also try making a Boolean variable first before doing proc freq like this:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data A2;
    set A;
    var2miss=var2='';
run;

proc freq data=A2;
    tables var2miss*month / missing outpct out=freq1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 02 Jul 2022 15:25:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-row-in-empty-table/m-p/821373#M324282</guid>
      <dc:creator>tarheel13</dc:creator>
      <dc:date>2022-07-02T15:25:20Z</dc:date>
    </item>
    <item>
      <title>Re: Add row in empty table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-row-in-empty-table/m-p/821375#M324283</link>
      <description>thanks</description>
      <pubDate>Sat, 02 Jul 2022 16:04:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-row-in-empty-table/m-p/821375#M324283</guid>
      <dc:creator>Toni2</dc:creator>
      <dc:date>2022-07-02T16:04:24Z</dc:date>
    </item>
    <item>
      <title>Re: Add row in empty table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-row-in-empty-table/m-p/821376#M324284</link>
      <description>thanks&lt;BR /&gt;</description>
      <pubDate>Sat, 02 Jul 2022 16:04:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-row-in-empty-table/m-p/821376#M324284</guid>
      <dc:creator>Toni2</dc:creator>
      <dc:date>2022-07-02T16:04:30Z</dc:date>
    </item>
  </channel>
</rss>

