<?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 Subset data based on the value included in the repeated observations in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Subset-data-based-on-the-value-included-in-the-repeated/m-p/452609#M114249</link>
    <description>&lt;P&gt;I have patients in my data with repeated observations. "uid"=unique identifier of patients. dos=date of survey. I'd like to&amp;nbsp;subset data where patients have future date of survey (2019). Below approach&amp;nbsp;outputs the rows only where dos=2019 but not along with previous years of&amp;nbsp;information&amp;nbsp;which I need to have to investigate the source of error.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your help is appreciated&amp;nbsp;to come up with data "want" from the code block below. Using SAS 9.4.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input uid dos;
cards;
1 2015
1 2016
1 2019
2 2017 
2 2018
3 2019
4 2015
4 2016
4 2017
5 2015
;

data want;
input uid dos;
cards;
1 2015
1 2016
1 2019
3 2019
;

proc sort data=have; 
by uid;
run; 
data wrong; set have;
by uid;
if dos in (2019) then output;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 09 Apr 2018 19:07:52 GMT</pubDate>
    <dc:creator>Cruise</dc:creator>
    <dc:date>2018-04-09T19:07:52Z</dc:date>
    <item>
      <title>Subset data based on the value included in the repeated observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subset-data-based-on-the-value-included-in-the-repeated/m-p/452609#M114249</link>
      <description>&lt;P&gt;I have patients in my data with repeated observations. "uid"=unique identifier of patients. dos=date of survey. I'd like to&amp;nbsp;subset data where patients have future date of survey (2019). Below approach&amp;nbsp;outputs the rows only where dos=2019 but not along with previous years of&amp;nbsp;information&amp;nbsp;which I need to have to investigate the source of error.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your help is appreciated&amp;nbsp;to come up with data "want" from the code block below. Using SAS 9.4.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input uid dos;
cards;
1 2015
1 2016
1 2019
2 2017 
2 2018
3 2019
4 2015
4 2016
4 2017
5 2015
;

data want;
input uid dos;
cards;
1 2015
1 2016
1 2019
3 2019
;

proc sort data=have; 
by uid;
run; 
data wrong; set have;
by uid;
if dos in (2019) then output;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Apr 2018 19:07:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subset-data-based-on-the-value-included-in-the-repeated/m-p/452609#M114249</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2018-04-09T19:07:52Z</dc:date>
    </item>
    <item>
      <title>Re: Subset data based on the value included in the repeated observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subset-data-based-on-the-value-included-in-the-repeated/m-p/452613#M114250</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;

create table want as
select * from have 
where uid in 
    (select uid from have where dos=2019);

quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Apr 2018 19:15:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subset-data-based-on-the-value-included-in-the-repeated/m-p/452613#M114250</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-04-09T19:15:54Z</dc:date>
    </item>
    <item>
      <title>Re: Subset data based on the value included in the repeated observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subset-data-based-on-the-value-included-in-the-repeated/m-p/452620#M114251</link>
      <description>worked out! but why? trying to visualize how SAS is calling data here</description>
      <pubDate>Mon, 09 Apr 2018 19:24:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subset-data-based-on-the-value-included-in-the-repeated/m-p/452620#M114251</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2018-04-09T19:24:10Z</dc:date>
    </item>
    <item>
      <title>Re: Subset data based on the value included in the repeated observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subset-data-based-on-the-value-included-in-the-repeated/m-p/452621#M114252</link>
      <description>&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;proc&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;sql&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;

create &lt;SPAN class="token statement"&gt;table&lt;/SPAN&gt; want as
&lt;SPAN class="token statement"&gt;select&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;from&lt;/SPAN&gt; have 
&lt;SPAN class="token statement"&gt;where&lt;/SPAN&gt; uid &lt;SPAN class="token operator"&gt;in /*selects only IDS from this list*/&lt;/SPAN&gt; 
    &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token statement"&gt;select&lt;/SPAN&gt; distinct uid &lt;SPAN class="token keyword"&gt;from&lt;/SPAN&gt; have &lt;SPAN class="token statement"&gt;where&lt;/SPAN&gt; dos&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;2019&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;; *&amp;lt;- this creates a list of IDs where it is 2019, should add the DISTNCT word here;&lt;/SPAN&gt;

&lt;SPAN class="token procnames"&gt;quit&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Apr 2018 19:26:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subset-data-based-on-the-value-included-in-the-repeated/m-p/452621#M114252</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-04-09T19:26:08Z</dc:date>
    </item>
  </channel>
</rss>

