<?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: Identifying observations on different submission indicators in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Identifying-observations-on-different-submission-indicators/m-p/732587#M228290</link>
    <description>&lt;P&gt;What does your desired result look like given this data ?&lt;/P&gt;</description>
    <pubDate>Fri, 09 Apr 2021 18:42:24 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2021-04-09T18:42:24Z</dc:date>
    <item>
      <title>Identifying observations on different submission indicators</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-observations-on-different-submission-indicators/m-p/732582#M228289</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID$ CC_IND CC1 CC2 CC6 CC8 CC9 CC10;
cards;
123 0 1 0 0 0 0 1 
123 1 0 1 0 0 0 1 
124 0 0 0 0 0 0 1
124 1 0 0 0 0 0 1
125 0 1 1 0 0 0 0
125 1 1 1 0 0 1 0
126 0 1 0 1 0 0 0
126 1 0 0 1 0 0 0
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Above is a sample of my table that contains roughly 8,000 IDs with flags indicating the ID has a CC present or not (=1 is present =0 is not present). There is also an indicator (C_IND) that lets me know what type of submission this was.&lt;BR /&gt;&lt;BR /&gt;I'd like to find which CC is populated as 1 by ID and CC_IND. Essentially I'm trying to find what CC's are present on ID's with a CC_IND=1 that are not populated on a CC_IND=0. &lt;BR /&gt;&lt;BR /&gt;An example would be ID 123 where CC2=1 on the CC_IND=1 record but not present on the CC_IND=0 record. &lt;/P&gt;</description>
      <pubDate>Fri, 09 Apr 2021 18:33:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-observations-on-different-submission-indicators/m-p/732582#M228289</guid>
      <dc:creator>bknitch</dc:creator>
      <dc:date>2021-04-09T18:33:04Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying observations on different submission indicators</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-observations-on-different-submission-indicators/m-p/732587#M228290</link>
      <description>&lt;P&gt;What does your desired result look like given this data ?&lt;/P&gt;</description>
      <pubDate>Fri, 09 Apr 2021 18:42:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-observations-on-different-submission-indicators/m-p/732587#M228290</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-04-09T18:42:24Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying observations on different submission indicators</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-observations-on-different-submission-indicators/m-p/732596#M228291</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&amp;nbsp; An optimal output would be to identify the header name as the output or an indication of what CC was in the submission identified. Or just retaining the flags where the observation was present on the C_IND=1 and not present on the C_IND=0&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 144pt;" border="0" width="192" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl66" style="height: 15.0pt; width: 48pt;"&gt;ID&lt;/TD&gt;
&lt;TD width="64" class="xl66" style="border-left: none; width: 48pt;"&gt;C_IND&lt;/TD&gt;
&lt;TD width="64" class="xl66" style="border-left: none; width: 48pt;"&gt;CC&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" class="xl65" style="height: 15.0pt; border-top: none;"&gt;123&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;CC2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" class="xl65" style="height: 15.0pt; border-top: none;"&gt;234&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;CC1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" class="xl65" style="height: 15.0pt; border-top: none;"&gt;657&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;CC8&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or something like this&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 384pt;" border="0" width="384pt" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl66" style="height: 15.0pt; width: 48pt;"&gt;ID&lt;/TD&gt;
&lt;TD width="64" class="xl66" style="border-left: none; width: 48pt;"&gt;C_IND&lt;/TD&gt;
&lt;TD width="64" class="xl66" style="border-left: none; width: 48pt;"&gt;CC1&lt;/TD&gt;
&lt;TD width="64" class="xl66" style="border-left: none; width: 48pt;"&gt;CC2&lt;/TD&gt;
&lt;TD width="64" class="xl66" style="border-left: none; width: 48pt;"&gt;CC6&lt;/TD&gt;
&lt;TD width="64" class="xl66" style="border-left: none; width: 48pt;"&gt;CC8&lt;/TD&gt;
&lt;TD width="64" class="xl66" style="border-left: none; width: 48pt;"&gt;CC9&lt;/TD&gt;
&lt;TD width="64" class="xl66" style="border-left: none; width: 48pt;"&gt;CC10&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" class="xl65" style="height: 15.0pt; border-top: none;"&gt;123&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" class="xl65" style="height: 15.0pt; border-top: none;"&gt;234&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" class="xl65" style="height: 15.0pt; border-top: none;"&gt;657&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Fri, 09 Apr 2021 18:54:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-observations-on-different-submission-indicators/m-p/732596#M228291</guid>
      <dc:creator>bknitch</dc:creator>
      <dc:date>2021-04-09T18:54:24Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying observations on different submission indicators</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-observations-on-different-submission-indicators/m-p/732606#M228295</link>
      <description>&lt;P&gt;Such code is easy with a long dataset layout:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID$ CC_IND CC1 CC2 CC6 CC8 CC9 CC10;
cards;
123 0 1 0 0 0 0 1 
123 1 0 1 0 0 0 1 
124 0 0 0 0 0 0 1
124 1 0 0 0 0 0 1
125 0 1 1 0 0 0 0
125 1 1 1 0 0 1 0
126 0 1 0 1 0 0 0
126 1 0 0 1 0 0 0
;

proc transpose
  data=have
  out=long (
    rename=(_name_=cc col1=submitted)
    where=(submitted = 1)
  )
;
by id cc_ind;
run;

proc sort data=long;
by id cc;
run;

data want;
merge
  long (in=zero where=(cc_ind = 0))
  long (in=one where=(cc_ind = 1))
;
by id cc;
if one and not zero;
keep id cc;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit: note that, with a long dataset layout, the code does not need to know the cc values present in the dataset. It is completely data-driven.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Apr 2021 19:13:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-observations-on-different-submission-indicators/m-p/732606#M228295</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-04-09T19:13:24Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying observations on different submission indicators</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-observations-on-different-submission-indicators/m-p/732609#M228296</link>
      <description>&lt;P&gt;Try something like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID$ CC_IND CC1 CC2 CC6 CC8 CC9 CC10;
cards;
123 0 1 0 0 0 0 1 
123 1 0 1 0 0 0 1 
124 0 0 0 0 0 0 1
124 1 0 0 0 0 0 1
125 0 1 1 0 0 0 0
125 1 1 1 0 0 1 0
126 0 1 0 1 0 0 0
126 1 0 0 1 0 0 0
;

data want(keep = ID cc);
   set have;
   where CC_IND = 1;
   array r{*} CC1 -- CC10;
   cc = vname(r[whichn(1, of r[*])]);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Apr 2021 19:07:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-observations-on-different-submission-indicators/m-p/732609#M228296</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-04-09T19:07:09Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying observations on different submission indicators</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-observations-on-different-submission-indicators/m-p/732611#M228297</link>
      <description>&lt;P&gt;Given your example data:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select 
    id,
    range(cc_ind) = 1 and min(cc_ind=cc1) = 1 as CC1,
    range(cc_ind) = 1 and min(cc_ind=cc2) = 1 as CC2,
    range(cc_ind) = 1 and min(cc_ind=cc6) = 1 as CC6,
    range(cc_ind) = 1 and min(cc_ind=cc8) = 1 as CC8,
    range(cc_ind) = 1 and min(cc_ind=cc9) = 1 as CC9,
    range(cc_ind) = 1 and min(cc_ind=cc10) = 1 as CC10
from have
group by id;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PGStats_0-1617995343967.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/57238i4FB9151A63E60046/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PGStats_0-1617995343967.png" alt="PGStats_0-1617995343967.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Apr 2021 19:09:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-observations-on-different-submission-indicators/m-p/732611#M228297</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2021-04-09T19:09:16Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying observations on different submission indicators</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-observations-on-different-submission-indicators/m-p/732615#M228300</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&amp;nbsp; thanks for the Proc SQL example, this actually works very well. Never thought about building a range out as i do something similar to calculate the CC flags. Thanks again!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Apr 2021 19:35:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-observations-on-different-submission-indicators/m-p/732615#M228300</guid>
      <dc:creator>bknitch</dc:creator>
      <dc:date>2021-04-09T19:35:31Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying observations on different submission indicators</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-observations-on-different-submission-indicators/m-p/732616#M228301</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&amp;nbsp; Thank you for the code. This actually did not capture the correct scenarios. It did reduce the data set to those ID's with a CC_IND=1 but it identified all of them, no matter if the same ID had a CC = to a CC with a CC_IND=1.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Meaning, it identified scenarios where the ID had both a CC_IND= 1 &amp;amp; 0 and a CC1=1 on both records and this codes output gave me that ID.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Apr 2021 19:38:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-observations-on-different-submission-indicators/m-p/732616#M228301</guid>
      <dc:creator>bknitch</dc:creator>
      <dc:date>2021-04-09T19:38:36Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying observations on different submission indicators</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-observations-on-different-submission-indicators/m-p/732618#M228303</link>
      <description>Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt; this worked really well. I thought about transposing it back to long and skinny from wide but didn't know the next steps from there. This was very helpful!</description>
      <pubDate>Fri, 09 Apr 2021 19:40:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-observations-on-different-submission-indicators/m-p/732618#M228303</guid>
      <dc:creator>bknitch</dc:creator>
      <dc:date>2021-04-09T19:40:05Z</dc:date>
    </item>
  </channel>
</rss>

