<?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: proc sql for repeat calulations using a multilevel dataset in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-for-repeat-calulations-using-a-multilevel-dataset/m-p/193540#M48626</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks PG for the explanation. That makes sense. Let me give it a try and I shall get back.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 27 May 2015 16:12:06 GMT</pubDate>
    <dc:creator>dr2014</dc:creator>
    <dc:date>2015-05-27T16:12:06Z</dc:date>
    <item>
      <title>proc sql for repeat calulations using a multilevel dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-for-repeat-calulations-using-a-multilevel-dataset/m-p/193535#M48621</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I am working with a dataset with the following multilevel layout.&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="margin-left: 4.65pt; padding: 0px 5.4pt; width: 275px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD nowrap="nowrap" style="border: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="64"&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="color: black;"&gt;agencyid&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border: solid windowtext 1.0pt; border-left: none; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="64"&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="color: black;"&gt;unitid&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border: solid windowtext 1.0pt; border-left: none; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="83"&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="color: black;"&gt;itemnumber&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border: solid windowtext 1.0pt; border-left: none; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="64"&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="color: black;"&gt;answer&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD nowrap="nowrap" style="border: solid windowtext 1.0pt; border-top: none; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="64"&gt;&lt;P align="right" style="margin-bottom: 0.0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;1&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="64"&gt;&lt;P align="right" style="margin-bottom: 0.0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;2&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="83"&gt;&lt;P align="right" style="margin-bottom: 0.0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;201&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="64"&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="color: black;"&gt;YES&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD nowrap="nowrap" style="border: solid windowtext 1.0pt; border-top: none; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="64"&gt;&lt;P align="right" style="margin-bottom: 0.0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;1&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="64"&gt;&lt;P align="right" style="margin-bottom: 0.0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;2&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="83"&gt;&lt;P align="right" style="margin-bottom: 0.0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;202&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="64"&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="color: black;"&gt;YES&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD nowrap="nowrap" style="border: solid windowtext 1.0pt; border-top: none; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="64"&gt;&lt;P align="right" style="margin-bottom: 0.0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;1&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="64"&gt;&lt;P align="right" style="margin-bottom: 0.0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;2&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="83"&gt;&lt;P align="right" style="margin-bottom: 0.0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;203&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="64"&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="color: black;"&gt;YES&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD nowrap="nowrap" style="border: solid windowtext 1.0pt; border-top: none; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="64"&gt;&lt;P align="right" style="margin-bottom: 0.0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;1&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="64"&gt;&lt;P align="right" style="margin-bottom: 0.0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;2&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="83"&gt;&lt;P align="right" style="margin-bottom: 0.0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;204&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="64"&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="color: black;"&gt;YES&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD nowrap="nowrap" style="border: solid windowtext 1.0pt; border-top: none; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="64"&gt;&lt;P align="right" style="margin-bottom: 0.0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;1&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="64"&gt;&lt;P align="right" style="margin-bottom: 0.0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;3&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="83"&gt;&lt;P align="right" style="margin-bottom: 0.0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;201&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="64"&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="color: black;"&gt;YES&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD nowrap="nowrap" style="border: solid windowtext 1.0pt; border-top: none; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="64"&gt;&lt;P align="right" style="margin-bottom: 0.0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;1&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="64"&gt;&lt;P align="right" style="margin-bottom: 0.0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;3&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="83"&gt;&lt;P align="right" style="margin-bottom: 0.0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;202&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="64"&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="color: black;"&gt;YES&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD nowrap="nowrap" style="border: solid windowtext 1.0pt; border-top: none; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="64"&gt;&lt;P align="right" style="margin-bottom: 0.0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;1&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="64"&gt;&lt;P align="right" style="margin-bottom: 0.0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;3&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="83"&gt;&lt;P align="right" style="margin-bottom: 0.0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;203&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="64"&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="color: black;"&gt;YES&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD nowrap="nowrap" style="border: solid windowtext 1.0pt; border-top: none; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="64"&gt;&lt;P align="right" style="margin-bottom: 0.0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;1&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="64"&gt;&lt;P align="right" style="margin-bottom: 0.0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;3&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="83"&gt;&lt;P align="right" style="margin-bottom: 0.0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;204&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="64"&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="color: black;"&gt;YES&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD nowrap="nowrap" style="border: solid windowtext 1.0pt; border-top: none; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="64"&gt;&lt;P align="right" style="margin-bottom: 0.0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;1&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="64"&gt;&lt;P align="right" style="margin-bottom: 0.0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;4&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="83"&gt;&lt;P align="right" style="margin-bottom: 0.0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;201&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="64"&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="color: black;"&gt;YES&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD nowrap="nowrap" style="border: solid windowtext 1.0pt; border-top: none; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="64"&gt;&lt;P align="right" style="margin-bottom: 0.0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;1&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="64"&gt;&lt;P align="right" style="margin-bottom: 0.0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;4&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="83"&gt;&lt;P align="right" style="margin-bottom: 0.0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;202&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="64"&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="color: black;"&gt;NO&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD nowrap="nowrap" style="border: solid windowtext 1.0pt; border-top: none; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="64"&gt;&lt;P align="right" style="margin-bottom: 0.0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;1&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="64"&gt;&lt;P align="right" style="margin-bottom: 0.0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;4&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="83"&gt;&lt;P align="right" style="margin-bottom: 0.0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;203&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="64"&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="color: black;"&gt;YES&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD nowrap="nowrap" style="border: solid windowtext 1.0pt; border-top: none; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="64"&gt;&lt;P align="right" style="margin-bottom: 0.0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;1&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="64"&gt;&lt;P align="right" style="margin-bottom: 0.0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;4&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="83"&gt;&lt;P align="right" style="margin-bottom: 0.0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;204&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="64"&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="color: black;"&gt;YES&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;The agency id ranges from 1 to 42. There are several unitids within an agencyid.&amp;nbsp; Each unitid will answer itemnumbers within a question. I need the number of units within an agency that have &lt;STRONG&gt;all 'yes' answers to all the itemnumbers 201 to 204.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For eg here the count of &lt;STRONG&gt;unique unitids that have a 'yes' response to all the itemnumbers is 2&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I improvise my code below to account for 'yes' responses to &lt;STRONG&gt;all the itemnumbers 201 to 204&lt;/STRONG&gt; ? The below code only gives me counts of unitids for any one of the itemnumbers with a yes answer.&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table c as&lt;/P&gt;&lt;P&gt;select agencyid,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; count(distinct unitid) &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; as numerator&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; from test&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* name of dataset*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where answer='Yes' and itemnumber in (201,202,203,204)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; group by agencyid;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;Please advice. Thanks !&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 May 2015 21:57:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql-for-repeat-calulations-using-a-multilevel-dataset/m-p/193535#M48621</guid>
      <dc:creator>dr2014</dc:creator>
      <dc:date>2015-05-26T21:57:18Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql for repeat calulations using a multilevel dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-for-repeat-calulations-using-a-multilevel-dataset/m-p/193536#M48622</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need a subquery :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc sql;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;create table want as&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;select agencyId, count(unitId) as nbUnits&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;from &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (select agencyId, unitId&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; from test&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; where answer = "YES" and itemNumber in (201, 202, 203, 204)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; group by agencyId, unitId&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; having count(distinct itemNumber)=4)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;group by agencyId;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;quit;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 May 2015 01:37:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql-for-repeat-calulations-using-a-multilevel-dataset/m-p/193536#M48622</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2015-05-27T01:37:28Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql for repeat calulations using a multilevel dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-for-repeat-calulations-using-a-multilevel-dataset/m-p/193537#M48623</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table c as&lt;/P&gt;&lt;P&gt;select agencyid,unitid from have&lt;/P&gt;&lt;P&gt;group by agencyid,unitid&lt;/P&gt;&lt;P&gt;having sum(answer='YES')=4;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 May 2015 02:29:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql-for-repeat-calulations-using-a-multilevel-dataset/m-p/193537#M48623</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2015-05-27T02:29:31Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql for repeat calulations using a multilevel dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-for-repeat-calulations-using-a-multilevel-dataset/m-p/193538#M48624</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi PGStats and stat@sas,&lt;/P&gt;&lt;P&gt;Thanks for your help, but I am still not getting the right answer...&lt;/P&gt;&lt;P&gt;The results table based on my example has to look like below&lt;/P&gt;&lt;TABLE border="1" cellpadding="0" cellspacing="0" style="margin-left: 4.65pt; border: medium none; padding: 0px 5.4pt; width: 181px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD nowrap="nowrap" style="border: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="67"&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="color: black;"&gt;agencyid&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border: solid windowtext 1.0pt; border-left: none; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="114"&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="color: black;"&gt;Unitid count&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD nowrap="nowrap" style="border: solid windowtext 1.0pt; border-top: none; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="67"&gt;&lt;P align="right" style="margin-bottom: 0.0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;1&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="114"&gt;&lt;P align="right" style="margin-bottom: 0.0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;2&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD nowrap="nowrap" style="border: solid windowtext 1.0pt; border-top: none; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="67"&gt;&lt;P align="right" style="margin-bottom: 0.0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;2&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="114"&gt;&lt;P align="right" style="margin-bottom: 0.0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;1&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD nowrap="nowrap" style="border: solid windowtext 1.0pt; border-top: none; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="67"&gt;&lt;P align="right" style="margin-bottom: 0.0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;3&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="bottom" width="114"&gt;&lt;P align="right" style="margin-bottom: 0.0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;6&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;I used both of your syntax and came up with this improvisation to my code. However, I get 0 rows and 2 columns . I not sure whats wrong ? Please let me know.&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table c as&lt;/P&gt;&lt;P&gt;select agencyid,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; count(distinct unitid) &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; as numerator&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; from test&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where itemid in (201,202,203,204)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; group by agencyid&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; having sum(answer='Yes')=4;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 May 2015 13:54:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql-for-repeat-calulations-using-a-multilevel-dataset/m-p/193538#M48624</guid>
      <dc:creator>dr2014</dc:creator>
      <dc:date>2015-05-27T13:54:01Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql for repeat calulations using a multilevel dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-for-repeat-calulations-using-a-multilevel-dataset/m-p/193539#M48625</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When I use my code with your example data (which covers agencyId=1 only) I get :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; agencyid&amp;nbsp;&amp;nbsp; nbUnits&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ------------------&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your new query, you group on agencyId and ask for the group condition &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;sum(answer='Yes')=4 . You are thus selecting agencies (not units) with 4 YES answers. That's why you need a subquery. The lowest (subquery) level groups on agency and units to extract the units with 4 YES answers. The higher level counts the selected units within each agency.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 May 2015 15:16:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql-for-repeat-calulations-using-a-multilevel-dataset/m-p/193539#M48625</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2015-05-27T15:16:10Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql for repeat calulations using a multilevel dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-for-repeat-calulations-using-a-multilevel-dataset/m-p/193540#M48626</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks PG for the explanation. That makes sense. Let me give it a try and I shall get back.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 May 2015 16:12:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql-for-repeat-calulations-using-a-multilevel-dataset/m-p/193540#M48626</guid>
      <dc:creator>dr2014</dc:creator>
      <dc:date>2015-05-27T16:12:06Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql for repeat calulations using a multilevel dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-for-repeat-calulations-using-a-multilevel-dataset/m-p/193541#M48627</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks PG ! It worked. I had an error in my syntax ! I broke your code down and ran it step wise.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 May 2015 17:38:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql-for-repeat-calulations-using-a-multilevel-dataset/m-p/193541#M48627</guid>
      <dc:creator>dr2014</dc:creator>
      <dc:date>2015-05-27T17:38:01Z</dc:date>
    </item>
  </channel>
</rss>

