<?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: Modify or Update working with two tables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Modify-or-Update-working-with-two-tables/m-p/449232#M283535</link>
    <description>&lt;P&gt;Please supply example data in a data step, like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data base;
input Name $ T_new $ Date :date7.;
cards;
A               yellow         10Jan18
A               yellow         20Feb17
A                black         10Jan18
B                red           15Dec15
C                green         12Jan16
C                brown         15Oct17
C                orange        09Jan16
C                blue          30Apr18
A                black         26Jan18
B                red           17Mar17
E                magenta       01Jan16
F                white         10Sep17
G                gray          05Nov18
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Test-running such a data step will reveal all typos made, like 20Fev17 or 31Apr18.&lt;/P&gt;&lt;P&gt;It's just a matter of basic courtesy to help the potential helpers (us) help you.&lt;/P&gt;&lt;P&gt;Both your updated codes:&lt;/P&gt;&lt;PRE data-lia-code-macro="true" data-lia-code-lang="sas" class="language-sas lia-code-sample"&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;
&lt;SPAN class="token keyword"&gt;update&lt;/SPAN&gt; WORK&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;Base as B
&lt;SPAN class="token keyword"&gt;set&lt;/SPAN&gt; PIN &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token string"&gt;'Hello'&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token statement"&gt;select&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;from&lt;/SPAN&gt; WORK&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;ADD&lt;/SPAN&gt; &lt;SPAN class="token statement"&gt;where&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt; B&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;Name &lt;SPAN class="token operator"&gt;EQ&lt;/SPAN&gt; Nome&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; AND 
&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;T_new &lt;SPAN class="token operator"&gt;EQ&lt;/SPAN&gt; B&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;T_final&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; AND
 &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;B&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;Date&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;GE&lt;/SPAN&gt; Start&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; AND 
&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;B&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;Date&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;LE&lt;/SPAN&gt; END&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&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;&lt;PRE data-lia-code-macro="true" data-lia-code-lang="sas" class="language-sas lia-code-sample"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; WORK&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;Base&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token keyword"&gt;set&lt;/SPAN&gt; WORK&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;ADD&lt;/SPAN&gt;
modify WORK&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;Base&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt; Name &lt;SPAN class="token operator"&gt;EQ&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;ADD&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;Nome&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; AND &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;T_new &lt;SPAN class="token operator"&gt;EQ&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;ADD&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;T_final&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; AND &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;Date&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;GE&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;ADD&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;Start&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; AND &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;Date&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;LE&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;ADD&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;END&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; &lt;SPAN class="token string"&gt;'Hello'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;throw obvious ERRORS that need to be fixed first.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I read your intentions right, try this:&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select
  a.*,
  case
    when b.name is not missing
    then 'Hello'
    else ''
  end as PIN
from work.base a left join work.add b
on a.name = b.name and a.t_new = b.t_new and b.start &amp;lt;= a.date &amp;lt;= b.end
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR data-mce-bogus="1" /&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 28 Mar 2018 07:15:25 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2018-03-28T07:15:25Z</dc:date>
    <item>
      <title>Modify or Update working with two tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modify-or-Update-working-with-two-tables/m-p/448988#M283528</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I try two search how to update or modify with two tables but the only result i found was about copy collumn(observations) from one table to another.&lt;/P&gt;&lt;P&gt;In my code i got it but only the observations that i update. Another option i got an update but with 10 times more observations(repeated because the comparisons).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want is basically update a variable(PIN) in my table (Work.Base) with a string like 'Hello' in all observations. The conditions are about observation B.Date between two other dates in other table(Work.ADD).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I try it with two options, SAS and SQL. And had some errors that i don't understand.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
update WORK.Base as B
set PIN = 'Hello' (select from WORK.ADD where (( B.Name EQ Nome) AND 
(T_new EQ B.T_final) AND
 (B.Date GE Start) AND 
(B.Date LE END));
quit;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WORK.Base;
set WORK.ADD
modify WORK.Base;
if (( Name EQ ADD.Nome) AND (T_new EQ ADD.T_final) AND (Date GE ADD.Start) AND (Date LE ADD.END)) then 'Hello';
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How i can do without the statement "by" because the&amp;nbsp;variables&amp;nbsp;has observations&amp;nbsp;very mixed and repeated.&lt;/P&gt;&lt;P&gt;If someone not understand i can write some examples.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Aleixo&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Mar 2018 17:50:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modify-or-Update-working-with-two-tables/m-p/448988#M283528</guid>
      <dc:creator>Aleixo</dc:creator>
      <dc:date>2018-03-27T17:50:44Z</dc:date>
    </item>
    <item>
      <title>Re: Modify or Update working with two tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modify-or-Update-working-with-two-tables/m-p/448990#M283529</link>
      <description>&lt;P&gt;This&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;B.Date date'n LE END&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;is invalid syntax, and causes further havoc down the line because of the unbalanced single quote.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Mar 2018 14:36:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modify-or-Update-working-with-two-tables/m-p/448990#M283529</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-03-27T14:36:17Z</dc:date>
    </item>
    <item>
      <title>Re: Modify or Update working with two tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modify-or-Update-working-with-two-tables/m-p/448994#M283530</link>
      <description>&lt;P&gt;sorry my bad copy. i rectify that code.&amp;nbsp;the problem is the same xD&lt;/P&gt;</description>
      <pubDate>Tue, 27 Mar 2018 14:41:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modify-or-Update-working-with-two-tables/m-p/448994#M283530</guid>
      <dc:creator>Aleixo</dc:creator>
      <dc:date>2018-03-27T14:41:35Z</dc:date>
    </item>
    <item>
      <title>Re: Modify or Update working with two tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modify-or-Update-working-with-two-tables/m-p/449005#M283531</link>
      <description>&lt;P&gt;It might help to show example data from the two data sets and what the desired result would be for that example data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You code contains many errors:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WORK.Base;
   set WORK.ADDmodify &lt;FONT color="#ff0000"&gt;WORK.Base.PIN&lt;/FONT&gt;;
   if (( &lt;FONT color="#ff0000"&gt;B.Name&lt;/FONT&gt; EQ Nome) AND (T_new EQ &lt;FONT color="#ff0000"&gt;B.T_final&lt;/FONT&gt;) AND (&lt;FONT color="#ff0000"&gt;B.Date&lt;/FONT&gt; GE Start) AND (&lt;FONT color="#ff0000"&gt;B.Date&lt;/FONT&gt; LE END)) then 'Hello';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you show the log for that data step you will have multiple errors as data step doesn't allow the B.name reference the way SQL does except for some very specific objects such as HASH. As soon as Proc SQL sees the DATA statement SAS ended the Proc SQL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Mar 2018 14:59:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modify-or-Update-working-with-two-tables/m-p/449005#M283531</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-03-27T14:59:58Z</dc:date>
    </item>
    <item>
      <title>Re: Modify or Update working with two tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modify-or-Update-working-with-two-tables/m-p/449020#M283532</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sorry that. i don't know why SAS code not accept enter in this forum.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Base:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Base

Name            T_new          Date              PIN
A               yellow         10Jan18
A               yellow         20Fev17
A                black         10Jan18
B                red           15Dec15
C                green         12Jan16
C                brown         15Oct17
C                orange        09Jan16
C                blue          31Apr18
A                black         26Jan18
B                red           17Mar17
E                magenta       01Jan16
F                white         10Sep17
G                gray          05Nov18&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Add&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Name            T_new               Start         End
A               yellow               10Jan17      11Jan18
A               yellow               11Fev17      18Fev17
A               black                10Jan17      05Nov17
B               red                  15Dec15      10Jan18
C               green                12Jan14       15Dec15
C               orange               12Jan2016    10Sep17
C               blue                 31Apr17      17Mar18
A               black                26Jan13       31Apr14
B               red                  17Mar11       20Mar12
E               magenta             17Dec15       20Mar16
G               gray                 05Nov16      15Oct17
A               yellow               10Jan15       11May15&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Base (Updated)&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Name            T_new          Date              PIN
A               yellow         10Jan18           Hello
A               yellow         20Fev17
A               black          10Jan18
B               red            10Dec15           Hello
C               green          12Jan16
C               brown          15Oct17
C               orange         09Jan16           Hello
C               blue           31Apr18
A               black          26Jan18
B               red            17Mar17           Hello
E               magenta        01Jan16           Hello
F               white          10Sep17
G               gray           05Nov18&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Sorry the examples but it is really complex my tables. That's the main idea.&lt;/P&gt;&lt;P&gt;I think it is dificult to understant the tables. I think i do not wrong the update &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;Aleixo&lt;/P&gt;</description>
      <pubDate>Tue, 27 Mar 2018 15:42:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modify-or-Update-working-with-two-tables/m-p/449020#M283532</guid>
      <dc:creator>Aleixo</dc:creator>
      <dc:date>2018-03-27T15:42:23Z</dc:date>
    </item>
    <item>
      <title>Re: Modify or Update working with two tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modify-or-Update-working-with-two-tables/m-p/449037#M283533</link>
      <description>&lt;P&gt;Copy and paste from non-text documents can be problematic. Is this supposed to be the structure for ADD:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Name T_new Start End
A yellow  10Jan17 11Jan18
A yellow  11Fev17 18Fev17
A black   10Jan17 05Nov17
B red     15Dec15 10Jan18
C green   12Jan14 15Dec15
C orange  02Jan16 10Sep17
C blue    31Apr17 17Mar18
A black   26Jan13 31Apr14
B red     17Mar11 20Mar12
E magenta 17Dec15 20Mar16
G gray    05Nov16 15Oct17
A yellow  10Jan15 11May15&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Mar 2018 15:53:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modify-or-Update-working-with-two-tables/m-p/449037#M283533</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-03-27T15:53:15Z</dc:date>
    </item>
    <item>
      <title>Re: Modify or Update working with two tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modify-or-Update-working-with-two-tables/m-p/449044#M283534</link>
      <description>&lt;P&gt;Yes. It is not perfect aligned. There are 4 columns.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The idea is&amp;nbsp;a column with group -&amp;gt; Name&lt;/P&gt;&lt;P&gt;Subgroup of Name is T_new, there are reapted because happen in diferent time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Start and End are the dates of a procedure.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Mar 2018 16:01:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modify-or-Update-working-with-two-tables/m-p/449044#M283534</guid>
      <dc:creator>Aleixo</dc:creator>
      <dc:date>2018-03-27T16:01:41Z</dc:date>
    </item>
    <item>
      <title>Re: Modify or Update working with two tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modify-or-Update-working-with-two-tables/m-p/449232#M283535</link>
      <description>&lt;P&gt;Please supply example data in a data step, like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data base;
input Name $ T_new $ Date :date7.;
cards;
A               yellow         10Jan18
A               yellow         20Feb17
A                black         10Jan18
B                red           15Dec15
C                green         12Jan16
C                brown         15Oct17
C                orange        09Jan16
C                blue          30Apr18
A                black         26Jan18
B                red           17Mar17
E                magenta       01Jan16
F                white         10Sep17
G                gray          05Nov18
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Test-running such a data step will reveal all typos made, like 20Fev17 or 31Apr18.&lt;/P&gt;&lt;P&gt;It's just a matter of basic courtesy to help the potential helpers (us) help you.&lt;/P&gt;&lt;P&gt;Both your updated codes:&lt;/P&gt;&lt;PRE data-lia-code-macro="true" data-lia-code-lang="sas" class="language-sas lia-code-sample"&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;
&lt;SPAN class="token keyword"&gt;update&lt;/SPAN&gt; WORK&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;Base as B
&lt;SPAN class="token keyword"&gt;set&lt;/SPAN&gt; PIN &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token string"&gt;'Hello'&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token statement"&gt;select&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;from&lt;/SPAN&gt; WORK&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;ADD&lt;/SPAN&gt; &lt;SPAN class="token statement"&gt;where&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt; B&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;Name &lt;SPAN class="token operator"&gt;EQ&lt;/SPAN&gt; Nome&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; AND 
&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;T_new &lt;SPAN class="token operator"&gt;EQ&lt;/SPAN&gt; B&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;T_final&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; AND
 &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;B&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;Date&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;GE&lt;/SPAN&gt; Start&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; AND 
&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;B&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;Date&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;LE&lt;/SPAN&gt; END&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&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;&lt;PRE data-lia-code-macro="true" data-lia-code-lang="sas" class="language-sas lia-code-sample"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; WORK&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;Base&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token keyword"&gt;set&lt;/SPAN&gt; WORK&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;ADD&lt;/SPAN&gt;
modify WORK&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;Base&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt; Name &lt;SPAN class="token operator"&gt;EQ&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;ADD&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;Nome&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; AND &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;T_new &lt;SPAN class="token operator"&gt;EQ&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;ADD&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;T_final&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; AND &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;Date&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;GE&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;ADD&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;Start&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; AND &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;Date&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;LE&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;ADD&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;END&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; &lt;SPAN class="token string"&gt;'Hello'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;throw obvious ERRORS that need to be fixed first.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I read your intentions right, try this:&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select
  a.*,
  case
    when b.name is not missing
    then 'Hello'
    else ''
  end as PIN
from work.base a left join work.add b
on a.name = b.name and a.t_new = b.t_new and b.start &amp;lt;= a.date &amp;lt;= b.end
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR data-mce-bogus="1" /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Mar 2018 07:15:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modify-or-Update-working-with-two-tables/m-p/449232#M283535</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-03-28T07:15:25Z</dc:date>
    </item>
    <item>
      <title>Re: Modify or Update working with two tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modify-or-Update-working-with-two-tables/m-p/449362#M283536</link>
      <description>&lt;P&gt;I am very sorry about my example data. Next time i will pay attention and will do in a&amp;nbsp;datastep.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much your help. Worked fine your solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Aleixo&lt;/P&gt;</description>
      <pubDate>Wed, 28 Mar 2018 14:51:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modify-or-Update-working-with-two-tables/m-p/449362#M283536</guid>
      <dc:creator>Aleixo</dc:creator>
      <dc:date>2018-03-28T14:51:20Z</dc:date>
    </item>
  </channel>
</rss>

