<?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: update dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/update-dataset/m-p/22112#M3583</link>
    <description>Flip,&lt;BR /&gt;
 I tried this:&lt;BR /&gt;
 proc sql;&lt;BR /&gt;
update final.spdata_2008_v1 as S set patient_birth_yr = (select distinct r.patient_birth_yr from up_date as R where S.provider=R.provider and s.patient_id=r.patient_id);&lt;BR /&gt;
Quit; &lt;BR /&gt;
Still gettig the error.</description>
    <pubDate>Wed, 25 Nov 2009 20:07:48 GMT</pubDate>
    <dc:creator>SASPhile</dc:creator>
    <dc:date>2009-11-25T20:07:48Z</dc:date>
    <item>
      <title>update dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/update-dataset/m-p/22108#M3579</link>
      <description>After uploading the data from various sources we realized that patient birth year is wrong.How to update the dataset with new values for patient birth year without effecting the data and without having to upload each file to fix the wrong field.&lt;BR /&gt;
The identifying key is by the provider.We have 15 providers like:&lt;BR /&gt;
Aetna,Axium etc etc.So for each provider I need to update the patient birth year.</description>
      <pubDate>Wed, 25 Nov 2009 16:56:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/update-dataset/m-p/22108#M3579</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2009-11-25T16:56:46Z</dc:date>
    </item>
    <item>
      <title>Re: update dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/update-dataset/m-p/22109#M3580</link>
      <description>A starting point. &lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
update datatable  set birthdate = (select birthdate from source_table where &lt;BR /&gt;
**match criteria**);&lt;BR /&gt;
Quit;</description>
      <pubDate>Wed, 25 Nov 2009 17:13:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/update-dataset/m-p/22109#M3580</guid>
      <dc:creator>Flip</dc:creator>
      <dc:date>2009-11-25T17:13:40Z</dc:date>
    </item>
    <item>
      <title>Re: update dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/update-dataset/m-p/22110#M3581</link>
      <description>I tried the following:&lt;BR /&gt;
 proc sql;&lt;BR /&gt;
update final.spdata_2008_v1 as S set patient_birth_yr = (select r.patient_birth_yr from up_date as R where S.provider=R.provider);&lt;BR /&gt;
Quit; &lt;BR /&gt;
&lt;BR /&gt;
I got this error message:&lt;BR /&gt;
5417   proc sql;&lt;BR /&gt;
5418  update final.spdata_2008_v1 as S set patient_birth_yr = (select r.patient_birth_yr from  try as R where S.provider=R.provider);&lt;BR /&gt;
ERROR: Subquery evaluated to more than one row.&lt;BR /&gt;
NOTE: Correlation values are: Provider='DIPLOMAT PHARMACY' .&lt;BR /&gt;
5419  Quit;</description>
      <pubDate>Wed, 25 Nov 2009 19:29:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/update-dataset/m-p/22110#M3581</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2009-11-25T19:29:58Z</dc:date>
    </item>
    <item>
      <title>Re: update dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/update-dataset/m-p/22111#M3582</link>
      <description>Are all birth years for a given provider the same?  That would seem strange.  If not, you need more identifying info such as a patient identifier.  If they are then a 'distinct' on the select might help.&lt;BR /&gt;
&lt;BR /&gt;
The message is self explanitory.  You are trying to update a single value with more than one result.  Your subquery must return a single row.</description>
      <pubDate>Wed, 25 Nov 2009 19:35:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/update-dataset/m-p/22111#M3582</guid>
      <dc:creator>Flip</dc:creator>
      <dc:date>2009-11-25T19:35:21Z</dc:date>
    </item>
    <item>
      <title>Re: update dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/update-dataset/m-p/22112#M3583</link>
      <description>Flip,&lt;BR /&gt;
 I tried this:&lt;BR /&gt;
 proc sql;&lt;BR /&gt;
update final.spdata_2008_v1 as S set patient_birth_yr = (select distinct r.patient_birth_yr from up_date as R where S.provider=R.provider and s.patient_id=r.patient_id);&lt;BR /&gt;
Quit; &lt;BR /&gt;
Still gettig the error.</description>
      <pubDate>Wed, 25 Nov 2009 20:07:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/update-dataset/m-p/22112#M3583</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2009-11-25T20:07:48Z</dc:date>
    </item>
    <item>
      <title>Re: update dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/update-dataset/m-p/22113#M3584</link>
      <description>The combination of provider and patient id must be unique in both tables to make this work, otherwise your subquery may result in with multiple rows.&lt;BR /&gt;
/Linus</description>
      <pubDate>Thu, 26 Nov 2009 08:02:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/update-dataset/m-p/22113#M3584</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2009-11-26T08:02:45Z</dc:date>
    </item>
    <item>
      <title>Re: update dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/update-dataset/m-p/22114#M3585</link>
      <description>the problem when using distinct is that your subquery still gets more than one row for the same provider and patient_id. That's why distinct will not help.&lt;BR /&gt;
&lt;BR /&gt;
Simple fix is that you update your where clause with some extra condition or group by statement.&lt;BR /&gt;
&lt;BR /&gt;
The simliest way could be using min or max function with distinct.&lt;BR /&gt;
But i don't think that is correct with some business logic.&lt;BR /&gt;
&lt;BR /&gt;
(select distinct &lt;B&gt;min&lt;/B&gt;(r.patient_birth_yr) from up_date as R where S.provider=R.provider and s.patient_id=r.patient_id);</description>
      <pubDate>Thu, 26 Nov 2009 09:13:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/update-dataset/m-p/22114#M3585</guid>
      <dc:creator>SAS_user</dc:creator>
      <dc:date>2009-11-26T09:13:59Z</dc:date>
    </item>
    <item>
      <title>Re: update dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/update-dataset/m-p/22115#M3586</link>
      <description>Actually Linus, the unique condition only needs to be present on the subquery.  It can update multiple records on the target table with a single record from the subquery.&lt;BR /&gt;
&lt;BR /&gt;
That said, the  thing that you must obtain is a unique record returned from the subquery for each record on the target table.  We can only guess at the overall structure of your data, so you must figure out the best way to get a single record returned.  Distinct may do it, assigning a record number and selecting the first or last one in a partition, are a couple of options.  &lt;BR /&gt;
&lt;BR /&gt;
Try collecting data from your source for a single patient to see the structure of the duplication.  You may want to create a temporary dataset to eliminate dupplicates if that is easier for you to clean up.</description>
      <pubDate>Fri, 27 Nov 2009 13:30:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/update-dataset/m-p/22115#M3586</guid>
      <dc:creator>Flip</dc:creator>
      <dc:date>2009-11-27T13:30:28Z</dc:date>
    </item>
  </channel>
</rss>

