<?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: SAS Query in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-Query/m-p/525726#M143071</link>
    <description>&lt;P&gt;Good morning, Sure I was sleeping and too late to the party&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input period date9. case $;
format period date9.;
datalines;
11DEC2018 ABC1
12DEC2018 ABC2
13DEC2018 ABC1
13DEC2018 ABC2
01JAN2019 ABC1
02JAN2019 ABC2
;
Run;

data _null_;
if _n_=1 then do;
   dcl hash H (ordered: "A") ;
   h.definekey  ("Period") ;
   h.definedata ("Period","cases") ;
   h.definedone () ;
end;
set test(rename=period=_period) end=lr;
Period=put(_period,monyy7.);
retain _p;
if period ne _p then do;cases=1;_p=period;end;
else cases+1;
h.replace();
if lr then h.output(dataset:'want');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 09 Jan 2019 14:53:23 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2019-01-09T14:53:23Z</dc:date>
    <item>
      <title>SAS Query</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Query/m-p/525665#M143048</link>
      <description>&lt;P&gt;I have the following data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test;&lt;BR /&gt;input period date9. case $;&lt;BR /&gt;format period date9.;&lt;BR /&gt;datalines;&lt;BR /&gt;11DEC2018 ABC1&lt;BR /&gt;12DEC2018 ABC2&lt;BR /&gt;13DEC2018 ABC1&lt;BR /&gt;13DEC2018 ABC2&lt;BR /&gt;01JAN2019 ABC1&lt;BR /&gt;02JAN2019 ABC2&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;Run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;May I know how to get the desired output - cases by month? Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Desired Output:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Period&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Cases&lt;/P&gt;&lt;P&gt;DEC2018&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&lt;/P&gt;&lt;P&gt;JAN2019&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jan 2019 09:56:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Query/m-p/525665#M143048</guid>
      <dc:creator>scb</dc:creator>
      <dc:date>2019-01-09T09:56:09Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Query</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Query/m-p/525669#M143051</link>
      <description>&lt;P&gt;One way&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input period date9. case $;
format period date9.;
datalines;
11DEC2018 ABC1
12DEC2018 ABC2
13DEC2018 ABC1
13DEC2018 ABC2
01JAN2019 ABC1
02JAN2019 ABC2
;
Run;

proc sql;
   create table want as
   select put(period, monyy7.) as period,
          count(period) as Cases
   from test
   group by calculated period;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Jan 2019 10:17:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Query/m-p/525669#M143051</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-01-09T10:17:29Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Query</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Query/m-p/525670#M143052</link>
      <description>&lt;P&gt;Another approach:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=work.test nway;
   class period;
   format period monyy7.;
   output out=work.want(drop=_type_ rename=(_freq_=Cases));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Jan 2019 10:20:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Query/m-p/525670#M143052</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-01-09T10:20:50Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Query</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Query/m-p/525726#M143071</link>
      <description>&lt;P&gt;Good morning, Sure I was sleeping and too late to the party&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input period date9. case $;
format period date9.;
datalines;
11DEC2018 ABC1
12DEC2018 ABC2
13DEC2018 ABC1
13DEC2018 ABC2
01JAN2019 ABC1
02JAN2019 ABC2
;
Run;

data _null_;
if _n_=1 then do;
   dcl hash H (ordered: "A") ;
   h.definekey  ("Period") ;
   h.definedata ("Period","cases") ;
   h.definedone () ;
end;
set test(rename=period=_period) end=lr;
Period=put(_period,monyy7.);
retain _p;
if period ne _p then do;cases=1;_p=period;end;
else cases+1;
h.replace();
if lr then h.output(dataset:'want');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Jan 2019 14:53:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Query/m-p/525726#M143071</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-01-09T14:53:23Z</dc:date>
    </item>
  </channel>
</rss>

