<?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: working with CMS medicare claims data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/working-with-CMS-medicare-claims-data/m-p/894640#M353390</link>
    <description>&lt;P&gt;There is a possibly useful alternative to the unconditional SET coding offered by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;- namely conditional SETs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assuming you might want a date by date history&amp;nbsp; (i.e. one record per date) containing the most recent data from each of the three sources (INPAT, OUTPAT, and PARTD), you can use a technique like the below (for sources sorted by ID/DATE).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set inpat  (keep=id date in=_in)
      outpat (keep=id date in=_out)
      partd  (keep=id date in=_partd) ;
  by id date;
  if _in    then set inpat  (rename=(date=date_inpat  dx=dx_inpat  hc=hc_inpat));
  if _out   then set outpat (rename=(date=date_outpat dx=dx_outpat hc=hc_outpat));
  if _partd then set partd  (rename=(date=date_partd  dx=dx_partd  hc=hc_partd));

  if last.date then output;
  if last.id then call missing(of _all_);
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Unlike the unconditional SET, variables from one source are NOT removed when data from another source are encountered, even if they are not from the same date.&amp;nbsp; Of course, it requires renaming all variables common to multiple sources, so you have no variable collisions.&amp;nbsp; The code above will generate a dataset with one record per ID/DATE, containing&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;ID and DATE (the most recent date among the 3 sources)&lt;/LI&gt;
&lt;LI&gt;DATE_INPAT&amp;nbsp; DX_INPAT HC_INPAT: the most recent DATE, DX, and HC from INPAT.&lt;/LI&gt;
&lt;LI&gt;DATE_OUTPAT&amp;nbsp; DX_OUTPAT HC_OUTPAT: the most recent DATE, DX, and HC from OUTPAT.&lt;/LI&gt;
&lt;LI&gt;DATE_PARTD&amp;nbsp; DX_PARTD HC_PARTD: the most recent DATE, DX, and HC from INPAT.&lt;/LI&gt;
&lt;LI&gt;Plus all the uniquely named variables from each source.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The advantage of this you have simultaneous information on most recent data from all sources, which your analyst might want to see.&amp;nbsp; You can also modify this code to remove "stale" data - (say the most recent PARTD is over 6 months old - so you could set just the PARTD vars to missing).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Caveat:&amp;nbsp;this program assumes each source has no more than one record per ID/DATE.&amp;nbsp; You could even make a minor tweak to accommodate cases where a given date has multiple obs from just one of the three source datasets (it need not be the same source for every multi-record date).&amp;nbsp; &amp;nbsp; Of course, if instead of simple dates, you have DATETIME stamps, you're less likely to encounter instances of multiple records from a given source with the same datetime stamp.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can see more about this approach, if interested, in my 2020 paper:&amp;nbsp;&amp;nbsp;&lt;A href="https://support.sas.com/resources/papers/proceedings20/5035-2020.pdf" target="_self"&gt;History Carried Forward, Future Carried Back: Mixing Time Series of Differing Frequencies.&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Sat, 16 Sep 2023 21:46:46 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2023-09-16T21:46:46Z</dc:date>
    <item>
      <title>working with CMS medicare claims data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/working-with-CMS-medicare-claims-data/m-p/894601#M353369</link>
      <description>&lt;P&gt;Does anyone have experience with combining/joining/merging (or whatever the best term is) different claims data? I have created 3 files containing information on treatments received by patients in 3 different settings (inpatient, outpatient, and partD) across a period of time hence patients have multiple observations depicting the treatment sequence.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is possible that a patient could have received treatment in different settings&amp;nbsp;at some different points in time and thus could have records in all of the three, hence I'm not sure merging/joining will be the best approach since I may lose information in the patient journey. I don't know if appending is the best either.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The point is I want to combine these 3 files into one overarching treatment file and still preserve the information in these separate files even if the variables are not common in all 3. That being said there are some common variables among the files.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also want to be able to create an indicator variable in the merged file so I&amp;nbsp;know where the event occurred. (source of file e.g Outpat, INp or Partd)&lt;/P&gt;&lt;P&gt;Any help will greatly be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks Note: the code presented here is the idea but not outputting the results I want and I know something is wrong hence my cry for help. I hope this makes sense.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="SAS_help.jpg" style="width: 941px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/88090iB3331593D8490BAD/image-size/large?v=v2&amp;amp;px=999" role="button" title="SAS_help.jpg" alt="SAS_help.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Sep 2023 03:20:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/working-with-CMS-medicare-claims-data/m-p/894601#M353369</guid>
      <dc:creator>crunchit</dc:creator>
      <dc:date>2023-09-16T03:20:41Z</dc:date>
    </item>
    <item>
      <title>Re: working with CMS medicare claims data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/working-with-CMS-medicare-claims-data/m-p/894607#M353372</link>
      <description>&lt;P&gt;I suspect that you do not want a join at all.&lt;/P&gt;
&lt;P&gt;Here is what I think might be more useful&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data drgs_merged;
    set table1
         table2
         table3
         indsname=dsn
   ;
   SourceFile=dsn;
run;&lt;/PRE&gt;
&lt;P&gt;This appends (or if you must think in SQL terms, unions) the datasets and adds a variable SourceFile that will have the name of the individual dataset. The Indsname= option creates a temporary variable that I have named DSN above that holds the name of the data set contributing the current observation. Temporary means that it will disappear so to keep the value(s) assign it to a variable.&lt;/P&gt;
&lt;P&gt;One reason I suspect very strongly that you do not want the join is because each value of ID is going to end up matched with every value of ID in the other sets and create multiple records. If ID=123, for example, appears in Table2 1 three times, Table2 two times and Table3 four times you would have ID=123 3*2*4=24 times in the output data set.&lt;/P&gt;
&lt;P&gt;The proposed solution I show will have each ID from each table only appear as many times total, i.e. 3+2+4=9.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Warning: If any of variables of the same name have different characteristics you may need more work. The append will not work if any variable of the same name has a different type in different sets (numeric in some, character in other set). Also if the same named variables are character but different lengths you might have data truncated. If you get that warning the solution to avoid truncation is to add a LENGTH statement before the SET statement with the name of the variable and a length equal to (or greater than) the longest defined value. Suppose you get a warning about the variable of DX has multiple lengths. Then add something like:&amp;nbsp;&amp;nbsp; Length dx $25. ; The number you use depends on the length needed.&amp;nbsp; If you have any questions use PROC CONTENTS for each of the data sets to find out the Length assigned to all the variables.&lt;/P&gt;</description>
      <pubDate>Sat, 16 Sep 2023 06:04:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/working-with-CMS-medicare-claims-data/m-p/894607#M353372</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-09-16T06:04:43Z</dc:date>
    </item>
    <item>
      <title>Re: working with CMS medicare claims data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/working-with-CMS-medicare-claims-data/m-p/894632#M353383</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;I suspected the basic approach as well but wasn't very confident that was the right approach. I agree with the Cartesian issue. I did run into that and had like 10x the data size. I will give this simple approach a shot and see how the data turns out. I appreciate it.&lt;/P&gt;</description>
      <pubDate>Sat, 16 Sep 2023 16:25:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/working-with-CMS-medicare-claims-data/m-p/894632#M353383</guid>
      <dc:creator>crunchit</dc:creator>
      <dc:date>2023-09-16T16:25:15Z</dc:date>
    </item>
    <item>
      <title>Re: working with CMS medicare claims data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/working-with-CMS-medicare-claims-data/m-p/894640#M353390</link>
      <description>&lt;P&gt;There is a possibly useful alternative to the unconditional SET coding offered by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;- namely conditional SETs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assuming you might want a date by date history&amp;nbsp; (i.e. one record per date) containing the most recent data from each of the three sources (INPAT, OUTPAT, and PARTD), you can use a technique like the below (for sources sorted by ID/DATE).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set inpat  (keep=id date in=_in)
      outpat (keep=id date in=_out)
      partd  (keep=id date in=_partd) ;
  by id date;
  if _in    then set inpat  (rename=(date=date_inpat  dx=dx_inpat  hc=hc_inpat));
  if _out   then set outpat (rename=(date=date_outpat dx=dx_outpat hc=hc_outpat));
  if _partd then set partd  (rename=(date=date_partd  dx=dx_partd  hc=hc_partd));

  if last.date then output;
  if last.id then call missing(of _all_);
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Unlike the unconditional SET, variables from one source are NOT removed when data from another source are encountered, even if they are not from the same date.&amp;nbsp; Of course, it requires renaming all variables common to multiple sources, so you have no variable collisions.&amp;nbsp; The code above will generate a dataset with one record per ID/DATE, containing&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;ID and DATE (the most recent date among the 3 sources)&lt;/LI&gt;
&lt;LI&gt;DATE_INPAT&amp;nbsp; DX_INPAT HC_INPAT: the most recent DATE, DX, and HC from INPAT.&lt;/LI&gt;
&lt;LI&gt;DATE_OUTPAT&amp;nbsp; DX_OUTPAT HC_OUTPAT: the most recent DATE, DX, and HC from OUTPAT.&lt;/LI&gt;
&lt;LI&gt;DATE_PARTD&amp;nbsp; DX_PARTD HC_PARTD: the most recent DATE, DX, and HC from INPAT.&lt;/LI&gt;
&lt;LI&gt;Plus all the uniquely named variables from each source.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The advantage of this you have simultaneous information on most recent data from all sources, which your analyst might want to see.&amp;nbsp; You can also modify this code to remove "stale" data - (say the most recent PARTD is over 6 months old - so you could set just the PARTD vars to missing).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Caveat:&amp;nbsp;this program assumes each source has no more than one record per ID/DATE.&amp;nbsp; You could even make a minor tweak to accommodate cases where a given date has multiple obs from just one of the three source datasets (it need not be the same source for every multi-record date).&amp;nbsp; &amp;nbsp; Of course, if instead of simple dates, you have DATETIME stamps, you're less likely to encounter instances of multiple records from a given source with the same datetime stamp.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can see more about this approach, if interested, in my 2020 paper:&amp;nbsp;&amp;nbsp;&lt;A href="https://support.sas.com/resources/papers/proceedings20/5035-2020.pdf" target="_self"&gt;History Carried Forward, Future Carried Back: Mixing Time Series of Differing Frequencies.&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Sep 2023 21:46:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/working-with-CMS-medicare-claims-data/m-p/894640#M353390</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2023-09-16T21:46:46Z</dc:date>
    </item>
    <item>
      <title>Re: working with CMS medicare claims data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/working-with-CMS-medicare-claims-data/m-p/894736#M353438</link>
      <description>&lt;P&gt;thanks,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;,&amp;nbsp;and for the reference. Good stuff&lt;/P&gt;</description>
      <pubDate>Mon, 18 Sep 2023 05:24:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/working-with-CMS-medicare-claims-data/m-p/894736#M353438</guid>
      <dc:creator>crunchit</dc:creator>
      <dc:date>2023-09-18T05:24:02Z</dc:date>
    </item>
  </channel>
</rss>

