<?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 How to remove overlapping observations when the variable is coded differently by input year in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-remove-overlapping-observations-when-the-variable-is/m-p/629057#M18857</link>
    <description>&lt;P&gt;Hi, I have a dataset that looks something like below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;subject&amp;nbsp; year&amp;nbsp; &amp;nbsp;disease&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2008&amp;nbsp; &amp;nbsp;123&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2009&amp;nbsp; &amp;nbsp; 1234&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2010&amp;nbsp; &amp;nbsp; &amp;nbsp;A123&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2009&amp;nbsp; &amp;nbsp; &amp;nbsp;2234&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2009&amp;nbsp; &amp;nbsp; &amp;nbsp; 3334&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2010&amp;nbsp; &amp;nbsp; &amp;nbsp;A234&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2010&amp;nbsp; &amp;nbsp; &amp;nbsp;A334&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2010&amp;nbsp; &amp;nbsp; &amp;nbsp;A444&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So basically, 123, 1234 and A123 are same disease but was coded differently every year.&lt;/P&gt;&lt;P&gt;I want to keep only the last observation of each disease per subject.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;subject&amp;nbsp; year&amp;nbsp; &amp;nbsp;disease&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2010&amp;nbsp; &amp;nbsp; &amp;nbsp;A123&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2010&amp;nbsp; &amp;nbsp; &amp;nbsp;A234&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2010&amp;nbsp; &amp;nbsp; &amp;nbsp;A334&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2010&amp;nbsp; &amp;nbsp; &amp;nbsp;A444&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Could anyone help me&amp;nbsp;how to solve this??&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 03 Mar 2020 09:31:14 GMT</pubDate>
    <dc:creator>lizwarr</dc:creator>
    <dc:date>2020-03-03T09:31:14Z</dc:date>
    <item>
      <title>How to remove overlapping observations when the variable is coded differently by input year</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-remove-overlapping-observations-when-the-variable-is/m-p/629057#M18857</link>
      <description>&lt;P&gt;Hi, I have a dataset that looks something like below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;subject&amp;nbsp; year&amp;nbsp; &amp;nbsp;disease&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2008&amp;nbsp; &amp;nbsp;123&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2009&amp;nbsp; &amp;nbsp; 1234&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2010&amp;nbsp; &amp;nbsp; &amp;nbsp;A123&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2009&amp;nbsp; &amp;nbsp; &amp;nbsp;2234&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2009&amp;nbsp; &amp;nbsp; &amp;nbsp; 3334&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2010&amp;nbsp; &amp;nbsp; &amp;nbsp;A234&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2010&amp;nbsp; &amp;nbsp; &amp;nbsp;A334&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2010&amp;nbsp; &amp;nbsp; &amp;nbsp;A444&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So basically, 123, 1234 and A123 are same disease but was coded differently every year.&lt;/P&gt;&lt;P&gt;I want to keep only the last observation of each disease per subject.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;subject&amp;nbsp; year&amp;nbsp; &amp;nbsp;disease&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2010&amp;nbsp; &amp;nbsp; &amp;nbsp;A123&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2010&amp;nbsp; &amp;nbsp; &amp;nbsp;A234&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2010&amp;nbsp; &amp;nbsp; &amp;nbsp;A334&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2010&amp;nbsp; &amp;nbsp; &amp;nbsp;A444&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Could anyone help me&amp;nbsp;how to solve this??&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2020 09:31:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-remove-overlapping-observations-when-the-variable-is/m-p/629057#M18857</guid>
      <dc:creator>lizwarr</dc:creator>
      <dc:date>2020-03-03T09:31:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove overlapping observations when the variable is coded differently by input year</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-remove-overlapping-observations-when-the-variable-is/m-p/629060#M18858</link>
      <description>&lt;P&gt;Here is one way&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input subject year disease $;
datalines;
1 2008 123
1 2009 1234
1 2010 A123
2 2009 2234
2 2009 3334
2 2010 A234
2 2010 A334
2 2010 A444
;

data want (drop=y);
    do _N_ = 1 by 1 until (last.subject);
        set have;
        by subject;
        y = year;
    end;
    do _N_ = 1 to _N_;
        set have;
        if year=y then output;
    end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;subject year  disease 
1       2010  A123 
2       2010  A234 
2       2010  A334 
2       2010  A444 &lt;/PRE&gt;</description>
      <pubDate>Tue, 03 Mar 2020 09:41:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-remove-overlapping-observations-when-the-variable-is/m-p/629060#M18858</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-03-03T09:41:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove overlapping observations when the variable is coded differently by input year</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-remove-overlapping-observations-when-the-variable-is/m-p/629065#M18859</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/314797"&gt;@lizwarr&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also use a PROC SQL to retrieve those observations:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	create table want as
	select *
	from have
	group by subject
	having year=max(year);
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Capture d’écran 2020-03-03 à 11.04.40.png" style="width: 200px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36534i81F0A5368D61D468/image-size/small?v=v2&amp;amp;px=200" role="button" title="Capture d’écran 2020-03-03 à 11.04.40.png" alt="Capture d’écran 2020-03-03 à 11.04.40.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2020 10:06:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-remove-overlapping-observations-when-the-variable-is/m-p/629065#M18859</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-03-03T10:06:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove overlapping observations when the variable is coded differently by input year</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-remove-overlapping-observations-when-the-variable-is/m-p/629210#M18860</link>
      <description>&lt;P&gt;Did you simplify the problem?&amp;nbsp; Are there going to be more entries in the input data sets, with additional diseases having multiple codes?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If so, I think you'll need to have a mapping table (or format) mapping all of the codes to uniform disease names.&amp;nbsp; The code will be more complicated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At first glance I thought this might be an opportunity to take advantage of the rarely-used GROUPFORMAT option, but on reflection I don't think there would be any benefit.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2020 18:35:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-remove-overlapping-observations-when-the-variable-is/m-p/629210#M18860</guid>
      <dc:creator>JackHamilton</dc:creator>
      <dc:date>2020-03-03T18:35:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove overlapping observations when the variable is coded differently by input year</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-remove-overlapping-observations-when-the-variable-is/m-p/630802#M18905</link>
      <description>&lt;P&gt;Indeed, I think I may have over-simplified the problem. It's data of hundreds of patients followed for 9 years with all kinds of chronic disease. I do have an excel file with codes of each year, but it's just that there are so many disease, I could't imagine unifying the codes manually...&lt;/P&gt;</description>
      <pubDate>Tue, 10 Mar 2020 06:02:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-remove-overlapping-observations-when-the-variable-is/m-p/630802#M18905</guid>
      <dc:creator>lizwarr</dc:creator>
      <dc:date>2020-03-10T06:02:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove overlapping observations when the variable is coded differently by input year</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-remove-overlapping-observations-when-the-variable-is/m-p/631193#M18918</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/314797"&gt;@lizwarr&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Indeed, I think I may have over-simplified the problem. It's data of hundreds of patients followed for 9 years with all kinds of chronic disease. I do have an excel file with codes of each year, but it's just that there are so many disease, I could't imagine unifying the codes manually...&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;In this Excel file is there any logical way to determine if two codes from two different years represent the same disease? If so then it wouldn't be too hard to create such a mapping table. We could actually simply generate a SAS Format which maps all code variations to the latest version.&lt;/P&gt;
&lt;P&gt;Above approach is of course only possible if there is a 1:1 relationship between the code variations over the years. Things will get much harder if codes change because of changing categorisations/higher differentiation of diseases like in year 1 a decease has code A but in year two it gets either code A1 or code A2 because coding becomes more differentiated. So to what would you now map code A from year 1? Code A1 or code A2? ...not a decease but just thinking how coding for a person within the autism spectrum might have changed over the years.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Mar 2020 10:46:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-remove-overlapping-observations-when-the-variable-is/m-p/631193#M18918</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-03-11T10:46:26Z</dc:date>
    </item>
  </channel>
</rss>

