<?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 to get count as zero when there are no subjects in the data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-count-as-zero-when-there-are-no-subjects-in-the-data/m-p/361797#M85378</link>
    <description>&lt;P&gt;Then my output is&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NS TRT&lt;/P&gt;
&lt;P&gt;2 &amp;nbsp; &amp;nbsp;30mg&lt;/P&gt;
&lt;P&gt;3 &amp;nbsp; &amp;nbsp;45mg&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp; placebo&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp; 15mg&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;</description>
    <pubDate>Thu, 25 May 2017 22:23:22 GMT</pubDate>
    <dc:creator>knveraraju91</dc:creator>
    <dc:date>2017-05-25T22:23:22Z</dc:date>
    <item>
      <title>How to get count as zero when there are no subjects in the data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-count-as-zero-when-there-are-no-subjects-in-the-data/m-p/361789#M85374</link>
      <description>&lt;P&gt;Dear,&lt;/P&gt;
&lt;P&gt;In the ouput result of the below program (in the grey box), I need to have zero count(NS=0) when there are no subjects present for the treatment.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Output needed:&lt;/P&gt;
&lt;P&gt;NS TRT&lt;/P&gt;
&lt;P&gt;2 &amp;nbsp; &amp;nbsp;30mg&lt;/P&gt;
&lt;P&gt;3 &amp;nbsp; &amp;nbsp;45mg&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp; placebo&lt;/P&gt;
&lt;P&gt;0 &amp;nbsp; &amp;nbsp; 15mg&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;output getting&lt;/P&gt;
&lt;P&gt;NS TRT&lt;/P&gt;
&lt;P&gt;2 &amp;nbsp; &amp;nbsp;30mg&lt;/P&gt;
&lt;P&gt;3 &amp;nbsp; &amp;nbsp;45mg&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp; placebo&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data one;
input id trt$ sflag$;
datalines;
1 45mg Y 
2 30mg Y
3 15mg N
4 30mg Y
5 45mg Y
6 plcebo Y
7 45mg Y
;
PROC SQL;
create table two as 
select count(distinct id) as NS,trt
from one
where sflag='Y'
group by trt;
quit;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I think I can get the output by &amp;nbsp;two proc transpose and two datsteps inbetween. But please suggest me if any better way to do this. Thank you very much&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;program I am running to get output I need&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc transpose data=two out=three(drop=_NAME_);&lt;BR /&gt; var NS;&lt;BR /&gt; id TRT;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data four;&lt;BR /&gt; set three;&lt;BR /&gt; array data _15mg _30mg _45mg placebo;&lt;BR /&gt; do over data;&lt;BR /&gt; if missing(data) then data=0;&lt;BR /&gt; end;&lt;BR /&gt; TOTAL=_15mg + _30mg + _45mg ;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc transpose data=four out=five;&lt;BR /&gt; var placebo _15mg _30mg _45mg total ;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 May 2017 21:59:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-count-as-zero-when-there-are-no-subjects-in-the-data/m-p/361789#M85374</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2017-05-25T21:59:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to get count as zero when there are no subjects in the data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-count-as-zero-when-there-are-no-subjects-in-the-data/m-p/361793#M85377</link>
      <description>&lt;P&gt;It can be done simpler. But what if your data looked like this?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
input id trt$ sflag$;
datalines;
1 45mg Y 
2 30mg Y
3 15mg N
4 30mg Y
5 45mg Y
6 plcebo Y
7 45mg Y
8 15mg Y
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So that you also had a 15mg observation with sflag='Y'. What would your desired output look like then?&lt;/P&gt;</description>
      <pubDate>Thu, 25 May 2017 22:12:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-count-as-zero-when-there-are-no-subjects-in-the-data/m-p/361793#M85377</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-05-25T22:12:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to get count as zero when there are no subjects in the data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-count-as-zero-when-there-are-no-subjects-in-the-data/m-p/361797#M85378</link>
      <description>&lt;P&gt;Then my output is&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NS TRT&lt;/P&gt;
&lt;P&gt;2 &amp;nbsp; &amp;nbsp;30mg&lt;/P&gt;
&lt;P&gt;3 &amp;nbsp; &amp;nbsp;45mg&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp; placebo&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp; 15mg&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Thu, 25 May 2017 22:23:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-count-as-zero-when-there-are-no-subjects-in-the-data/m-p/361797#M85378</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2017-05-25T22:23:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to get count as zero when there are no subjects in the data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-count-as-zero-when-there-are-no-subjects-in-the-data/m-p/362312#M85583</link>
      <description>&lt;P&gt;I would probably try something like&lt;/P&gt;&lt;PRE&gt;proc sql;
&amp;nbsp; create table want as
&amp;nbsp; select trt,sum(sflag='Y')
&amp;nbsp; from have&lt;BR /&gt;  group by trt;
quit;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 28 May 2017 17:01:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-count-as-zero-when-there-are-no-subjects-in-the-data/m-p/362312#M85583</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2017-05-28T17:01:26Z</dc:date>
    </item>
  </channel>
</rss>

