<?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: Using coalesce to update data in one column form one table with data in one column form another in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-coalesce-to-update-data-in-one-column-form-one-table-with/m-p/820634#M323933</link>
    <description>thank you!</description>
    <pubDate>Tue, 28 Jun 2022 04:04:22 GMT</pubDate>
    <dc:creator>2222</dc:creator>
    <dc:date>2022-06-28T04:04:22Z</dc:date>
    <item>
      <title>Using coalesce to update data in one column form one table with data in one column form another tabl</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-coalesce-to-update-data-in-one-column-form-one-table-with/m-p/820455#M323834</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I am trying to figure out the best way to fill in blanks/update data in one data table with data form a column in another data table. I have tried the hash/define method, but I couldn't get it to work. So now I'm trying this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;select coalesce (MOBILENO, MOBILE) as MOST_RECENT_MN&lt;BR /&gt;from AP;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I dont really know how to use this function and the doco is over my head.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically I would like to select the MOBILENO (when it exists), which is in the AP table and have that overwrite the MOBILE column which is in the M1 table. Where the MOBILENO does not exist then the MOBILE column is fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Greatly appreciate any help or direction.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2022 04:12:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-coalesce-to-update-data-in-one-column-form-one-table-with/m-p/820455#M323834</guid>
      <dc:creator>2222</dc:creator>
      <dc:date>2022-06-27T04:12:23Z</dc:date>
    </item>
    <item>
      <title>Re: Using coalesce to update data in one column form one table with data in one column form another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-coalesce-to-update-data-in-one-column-form-one-table-with/m-p/820456#M323835</link>
      <description>&lt;P&gt;You are on the right track but you've only listed one table in your query. It should look more like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table Want as 
select coalesce (MOBILENO, MOBILE) as MOST_RECENT_MN
from AP
left join M1
on AP.join_column = M1.join_column
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I don't know what the joining rules are for your tables so you need to supply that. Putting MOBILENO first in the COALESCE means what will be used if populated, otherwise MOBILE is used.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2022 04:46:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-coalesce-to-update-data-in-one-column-form-one-table-with/m-p/820456#M323835</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-06-27T04:46:03Z</dc:date>
    </item>
    <item>
      <title>Re: Using coalesce to update data in one column form one table with data in one column form another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-coalesce-to-update-data-in-one-column-form-one-table-with/m-p/820461#M323838</link>
      <description>&lt;P&gt;thank you for that, unfortunately I am getting an ambiguous reference error because MOBILE is in two datasets&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2022 06:06:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-coalesce-to-update-data-in-one-column-form-one-table-with/m-p/820461#M323838</guid>
      <dc:creator>2222</dc:creator>
      <dc:date>2022-06-27T06:06:34Z</dc:date>
    </item>
    <item>
      <title>Re: Using coalesce to update data in one column form one table with data in one column form another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-coalesce-to-update-data-in-one-column-form-one-table-with/m-p/820482#M323848</link>
      <description>&lt;P&gt;In SQL, you need to be clear about where a variable is supposed to come from; define table aliases in the FROM clause and use them when addressing variables.&lt;/P&gt;
&lt;P&gt;e.g.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
  select
    t1.id,
    t1.var_a,
    (t1.var_a - t2.var_b) as diff
  from table_a t1 left join table_b t2
  on t1.id = t2.id
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Jun 2022 08:41:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-coalesce-to-update-data-in-one-column-form-one-table-with/m-p/820482#M323848</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-06-27T08:41:51Z</dc:date>
    </item>
    <item>
      <title>Re: Using coalesce to update data in one column form one table with data in one column form another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-coalesce-to-update-data-in-one-column-form-one-table-with/m-p/820620#M323920</link>
      <description>thank you, and does this work if the variable comes from the same table as the variable it is updating? then I drop the variable after i have used it to update the variable that had missing values?</description>
      <pubDate>Tue, 28 Jun 2022 01:57:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-coalesce-to-update-data-in-one-column-form-one-table-with/m-p/820620#M323920</guid>
      <dc:creator>2222</dc:creator>
      <dc:date>2022-06-28T01:57:11Z</dc:date>
    </item>
    <item>
      <title>Re: Using coalesce to update data in one column form one table with data in one column form another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-coalesce-to-update-data-in-one-column-form-one-table-with/m-p/820623#M323923</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/404165"&gt;@2222&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;thank you, and does this work if the variable comes from the same table as the variable it is updating? then I drop the variable after i have used it to update the variable that had missing values?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;In that case there is no need for SQL at all.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set AP;
  most_recent_mn = coalesceC(MOBILENO, MOBILE);
  drop MOBILENO;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Unless you are doing something extremely complex with extremely large datasets it is much better to create a NEW dataset when making changes to the data with code instead of making changes to an existing dataset.&amp;nbsp; That way you can always correct any problems and re-run the code without having to worry that the mistakes have destroyed the source data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2022 02:26:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-coalesce-to-update-data-in-one-column-form-one-table-with/m-p/820623#M323923</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-06-28T02:26:30Z</dc:date>
    </item>
    <item>
      <title>Re: Using coalesce to update data in one column form one table with data in one column form another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-coalesce-to-update-data-in-one-column-form-one-table-with/m-p/820634#M323933</link>
      <description>thank you!</description>
      <pubDate>Tue, 28 Jun 2022 04:04:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-coalesce-to-update-data-in-one-column-form-one-table-with/m-p/820634#M323933</guid>
      <dc:creator>2222</dc:creator>
      <dc:date>2022-06-28T04:04:22Z</dc:date>
    </item>
  </channel>
</rss>

