<?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: Need help managing this data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-help-managing-this-data/m-p/570964#M161053</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input UserID    Consent $;
cards;
1                 Y
2                 Y
2                N
3                N
3                N
4                Y
4                Y
4                N
;


proc sql;
create table want as
select distinct *
from have
group by userid
having max(consent)=consent;
quit;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 03 Jul 2019 13:35:33 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2019-07-03T13:35:33Z</dc:date>
    <item>
      <title>Need help managing this data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-managing-this-data/m-p/570959#M161051</link>
      <description>&lt;P&gt;So i have a data set that has multiple observations for some users, but I only want 1 observation for each unique user ID depending on the variable 'consent'.&amp;nbsp; If a member has multiple Yes (Y) for consent, I want to keep one Y observation, if they have multiple No (N) for consent, I want to keep one N observation, and if they have some Y and some N, I only want to keep one Y observation.&amp;nbsp; Example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;HAVE:&lt;/P&gt;&lt;P&gt;User ID&amp;nbsp; &amp;nbsp; Consent&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Y&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Y&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; N&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; N&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; N&lt;/P&gt;&lt;P&gt;4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Y&lt;/P&gt;&lt;P&gt;4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Y&lt;/P&gt;&lt;P&gt;4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; N&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;WANT&lt;/P&gt;&lt;P&gt;User ID&amp;nbsp; Consent&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Y&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Y&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;N&lt;/P&gt;&lt;P&gt;4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Y&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jul 2019 13:29:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-managing-this-data/m-p/570959#M161051</guid>
      <dc:creator>jmmedina25</dc:creator>
      <dc:date>2019-07-03T13:29:14Z</dc:date>
    </item>
    <item>
      <title>Re: Need help managing this data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-managing-this-data/m-p/570963#M161052</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input UserID Consent $;
datalines;
1 Y
2 Y
2 N
3 N
3 N
4 Y
4 Y
4 N
;

proc sort data=have;
    by UserID Consent;
run;

data want;
    set have;
    by UserID;
    if last.UserID;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 03 Jul 2019 13:33:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-managing-this-data/m-p/570963#M161052</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-07-03T13:33:03Z</dc:date>
    </item>
    <item>
      <title>Re: Need help managing this data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-managing-this-data/m-p/570964#M161053</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input UserID    Consent $;
cards;
1                 Y
2                 Y
2                N
3                N
3                N
4                Y
4                Y
4                N
;


proc sql;
create table want as
select distinct *
from have
group by userid
having max(consent)=consent;
quit;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 03 Jul 2019 13:35:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-managing-this-data/m-p/570964#M161053</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-07-03T13:35:33Z</dc:date>
    </item>
    <item>
      <title>Re: Need help managing this data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-managing-this-data/m-p/570968#M161054</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input UserID    Consent $;
cards;
1                 Y
2                 Y
2                N
3                N
3                N
4                Y
4                Y
4                N
;
data want;
do until(last.userid);
set have;
by userid;
if consent='Y' and _f=. then do; output;_f=1;end;
else if _f=. and last.userid then output;
end;
drop _f;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 03 Jul 2019 13:47:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-managing-this-data/m-p/570968#M161054</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-07-03T13:47:30Z</dc:date>
    </item>
  </channel>
</rss>

