<?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: ADD value from other tables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/ADD-value-from-other-tables/m-p/835674#M330401</link>
    <description>&lt;P&gt;How would add that value for a single value?&lt;BR /&gt;Can you show an example of what those tables look like and how that join would work for single table?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You'll need to join with multiple tables and exactly how can vary...multiple ways to do many things as usual.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/419704"&gt;@elsfy&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can i add the corresponding value from the right table ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a dataset A with ID and DATE variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Dataset A :&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;ID&amp;nbsp;&amp;nbsp;&amp;nbsp; DATE&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 201504&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 201001&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;and so on...&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;201504 refers to April, 2015, etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to add a variable "quantity" to this dataset A.&lt;/P&gt;
&lt;P&gt;This variable is available in a list of datasets that all have the same name, except their date. So i have other datasets as :&lt;/P&gt;
&lt;P&gt;- TABLE_201001&lt;/P&gt;
&lt;P&gt;-TABLE_201002&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;-TABLE_201504&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;These datasets are constructed like this, e.g TABLE_201001 :&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;ID&amp;nbsp;&amp;nbsp; quantity date&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 445 &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 201001 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 356&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 201001&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;See here the key merge is ID but also the information about the date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can i have sth like this in dataset A with quantity coming from the right table ?&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;ID&amp;nbsp;&amp;nbsp;&amp;nbsp; DATE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; QUANTITY&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 201504&amp;nbsp;&amp;nbsp;&amp;nbsp; 445&amp;nbsp;&amp;nbsp;&amp;nbsp; /*coming from dataset TABLE_201504 */&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 201001&amp;nbsp;&amp;nbsp;&amp;nbsp; 356&amp;nbsp;&amp;nbsp;&amp;nbsp; /* coming from dataset TABLE_201001 */&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't want to merge TABLE datasets as i have a lot of them and only showing here an exemple.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thought of doing a loop&amp;nbsp; with tables and if date values match then adding the value for the ID observation, else keep looking for other datasets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 28 Sep 2022 18:00:34 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2022-09-28T18:00:34Z</dc:date>
    <item>
      <title>ADD value from other tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ADD-value-from-other-tables/m-p/835670#M330399</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can i add the corresponding value from the right table ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a dataset A with ID and DATE variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Dataset A :&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;ID&amp;nbsp;&amp;nbsp;&amp;nbsp; DATE&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 201504&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 201001&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;and so on...&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;201504 refers to April, 2015, etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to add a variable "quantity" to this dataset A.&lt;/P&gt;
&lt;P&gt;This variable is available in a list of datasets that all have the same name, except their date. So i have other datasets as :&lt;/P&gt;
&lt;P&gt;- TABLE_201001&lt;/P&gt;
&lt;P&gt;-TABLE_201002&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;-TABLE_201504&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;These datasets are constructed like this, e.g TABLE_201001 :&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;ID&amp;nbsp;&amp;nbsp; quantity date&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 445 &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 201001 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 356&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 201001&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;See here the key merge is ID but also the information about the date. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can i have sth like this in dataset A with quantity coming from the right table ?&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;ID&amp;nbsp;&amp;nbsp;&amp;nbsp; DATE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; QUANTITY&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 201504&amp;nbsp;&amp;nbsp;&amp;nbsp; 445&amp;nbsp;&amp;nbsp;&amp;nbsp; /*coming from dataset TABLE_201504 */&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 201001&amp;nbsp;&amp;nbsp;&amp;nbsp; 356&amp;nbsp;&amp;nbsp;&amp;nbsp; /* coming from dataset TABLE_201001 */&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't want to merge TABLE datasets as i have a lot of them and only showing here an exemple.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thought of doing a loop&amp;nbsp; with tables and if date values match then adding the value for the ID observation, else keep looking for other datasets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Sep 2022 17:43:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ADD-value-from-other-tables/m-p/835670#M330399</guid>
      <dc:creator>elsfy</dc:creator>
      <dc:date>2022-09-28T17:43:29Z</dc:date>
    </item>
    <item>
      <title>Re: ADD value from other tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ADD-value-from-other-tables/m-p/835671#M330400</link>
      <description>&lt;P&gt;Do all the&amp;nbsp;&lt;SPAN&gt;TABLE_YYYYMM tables have the same structure?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Sep 2022 17:51:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ADD-value-from-other-tables/m-p/835671#M330400</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-09-28T17:51:52Z</dc:date>
    </item>
    <item>
      <title>Re: ADD value from other tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ADD-value-from-other-tables/m-p/835674#M330401</link>
      <description>&lt;P&gt;How would add that value for a single value?&lt;BR /&gt;Can you show an example of what those tables look like and how that join would work for single table?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You'll need to join with multiple tables and exactly how can vary...multiple ways to do many things as usual.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/419704"&gt;@elsfy&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can i add the corresponding value from the right table ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a dataset A with ID and DATE variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Dataset A :&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;ID&amp;nbsp;&amp;nbsp;&amp;nbsp; DATE&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 201504&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 201001&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;and so on...&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;201504 refers to April, 2015, etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to add a variable "quantity" to this dataset A.&lt;/P&gt;
&lt;P&gt;This variable is available in a list of datasets that all have the same name, except their date. So i have other datasets as :&lt;/P&gt;
&lt;P&gt;- TABLE_201001&lt;/P&gt;
&lt;P&gt;-TABLE_201002&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;-TABLE_201504&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;These datasets are constructed like this, e.g TABLE_201001 :&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;ID&amp;nbsp;&amp;nbsp; quantity date&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 445 &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 201001 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 356&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 201001&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;See here the key merge is ID but also the information about the date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can i have sth like this in dataset A with quantity coming from the right table ?&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;ID&amp;nbsp;&amp;nbsp;&amp;nbsp; DATE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; QUANTITY&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 201504&amp;nbsp;&amp;nbsp;&amp;nbsp; 445&amp;nbsp;&amp;nbsp;&amp;nbsp; /*coming from dataset TABLE_201504 */&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 201001&amp;nbsp;&amp;nbsp;&amp;nbsp; 356&amp;nbsp;&amp;nbsp;&amp;nbsp; /* coming from dataset TABLE_201001 */&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't want to merge TABLE datasets as i have a lot of them and only showing here an exemple.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thought of doing a loop&amp;nbsp; with tables and if date values match then adding the value for the ID observation, else keep looking for other datasets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Sep 2022 18:00:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ADD-value-from-other-tables/m-p/835674#M330401</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-09-28T18:00:34Z</dc:date>
    </item>
    <item>
      <title>Re: ADD value from other tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ADD-value-from-other-tables/m-p/835676#M330402</link>
      <description>Yes</description>
      <pubDate>Wed, 28 Sep 2022 18:08:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ADD-value-from-other-tables/m-p/835676#M330402</guid>
      <dc:creator>elsfy</dc:creator>
      <dc:date>2022-09-28T18:08:26Z</dc:date>
    </item>
    <item>
      <title>Re: ADD value from other tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ADD-value-from-other-tables/m-p/835677#M330403</link>
      <description>&lt;P&gt;Ok. See if you can use this as a template then&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
input ID DATE :yymmn6.;
format DATE yymmn6.;
datalines;
1 201504
2 201001
;

data TABLE_201001;
input ID quantity date :yymmn6.;
format date yymmn6.;
datalines;
1 445 201001 
2 356 201001 
;  

data TABLE_201504;
input ID quantity date :yymmn6.;
format date yymmn6.;
datalines;
1 445 201504 
2 356 201504 
;  

data table;
   set table_:;
run;

proc sql;
   create table want as
   select a.*
        , quantity
   from a left join table t
   on  a.ID   = t.ID
   and a.date = t.date
   ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Sep 2022 18:16:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ADD-value-from-other-tables/m-p/835677#M330403</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-09-28T18:16:14Z</dc:date>
    </item>
    <item>
      <title>Re: ADD value from other tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ADD-value-from-other-tables/m-p/835681#M330404</link>
      <description>Don’t know if this answers to your question but i thought of doing sth like this :&lt;BR /&gt;Proc sql;&lt;BR /&gt;Create table want as &lt;BR /&gt;Select a.*,&lt;BR /&gt;CASE WHEN a.date = b.date then b.quantity&lt;BR /&gt;Else .&lt;BR /&gt;End as quantity&lt;BR /&gt;From A a &lt;BR /&gt;Left join TABLE_YYYYMM b on a.id =b.id &lt;BR /&gt;; quit&lt;BR /&gt;;&lt;BR /&gt;this code can be better if i could loop and search if the information is in TABLE_201010 then add quantity from this table, else keep looking to other tables until it matches the date value in A</description>
      <pubDate>Wed, 28 Sep 2022 18:18:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ADD-value-from-other-tables/m-p/835681#M330404</guid>
      <dc:creator>elsfy</dc:creator>
      <dc:date>2022-09-28T18:18:07Z</dc:date>
    </item>
    <item>
      <title>Re: ADD value from other tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ADD-value-from-other-tables/m-p/835685#M330405</link>
      <description>&lt;P&gt;Do the TABLE_201001 tables have more than one record?&lt;/P&gt;
&lt;P&gt;Is this supposed to match on another variable? (Not at all stated) If so state the variable , is that variable duplicated in any of the TABLE_201001 data sets?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Is the value in your data set A actually as SAS date value?? If so, show us what format is currently applied to the variable. If not you likely should create an actual SAS date value as that will allow many things that random number/character combinations impersonating dates won't let you do.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In any case you need to provide details about your existing data sets such as any other matching variables, variable types and possibly formats.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a brief example of combining a couple data sets and pulling part of the data set name as a value in a combined data set.&lt;/P&gt;
&lt;PRE&gt;data example_1;
   input id value;
datalines;
1 23
2 34
;

data example_2;
  input id value;
datalines;
1 14
2 77
;

data combined;
   set example_: indsname=setname;
   indicator = scan(setname,2,'_');
run;&lt;/PRE&gt;
&lt;P&gt;The first two data steps just create data for an example. The third data set combined shows how to combine a lot of similarly named data sets with the : list builder. The : immediately after Example_ tells SAS that you want to use ALL of the data sets whose names start with Example_.&lt;/P&gt;
&lt;P&gt;The INDSNAME option adds a temporary variable that holds the names of the data sets, in this case Setname, that will not be added to the data set. So you can use the variable Setname, which will have the library and data set name for parsing. In this case, similar to your Table_201001 sets, the _ separates the stem of the name, Table, from the indicator value 201001. So the Scan function can pull that from the Setname variable using the _ as a delimiter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then something like:&lt;/P&gt;
&lt;PRE&gt;data control;
   input id indicator $;
datalines;
1 3
1 2
1 1
2 2
3 2
;

proc sort data=control;
   by id indicator;
run;

proc sort data=combined;
   by id indicator;
run;

data want;
   merge control combined;
   by id indicator;
run;

&lt;/PRE&gt;
&lt;P&gt;To add values.&lt;/P&gt;
&lt;P&gt;Note: I purposely included values in the Control set that did not have match.&lt;/P&gt;
&lt;P&gt;Note also that the Indicator variable in the Control set is Character. That is so the value will match the Indicator made in the Combined set. Which is &lt;STRONG&gt;why we need details of your variables&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;If there is NOT a second variable in Control set to match on then this exercise may very well be a complete waste of time without considerably more actual example data as which values to match may not be obvious.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Sep 2022 18:21:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ADD-value-from-other-tables/m-p/835685#M330405</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-09-28T18:21:19Z</dc:date>
    </item>
    <item>
      <title>Re: ADD value from other tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ADD-value-from-other-tables/m-p/835690#M330406</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;I think this was merged or added to a different posts by accident?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Sep 2022 18:34:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ADD-value-from-other-tables/m-p/835690#M330406</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-09-28T18:34:29Z</dc:date>
    </item>
    <item>
      <title>Re: ADD value from other tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ADD-value-from-other-tables/m-p/835691#M330407</link>
      <description>I don’t know why my post is under another</description>
      <pubDate>Wed, 28 Sep 2022 18:45:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ADD-value-from-other-tables/m-p/835691#M330407</guid>
      <dc:creator>elsfy</dc:creator>
      <dc:date>2022-09-28T18:45:17Z</dc:date>
    </item>
    <item>
      <title>Re: ADD value from other tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ADD-value-from-other-tables/m-p/835692#M330408</link>
      <description>Tested your code using only few datasets and it works but one question, this code would be too long if i have many other datasets no ? So what would be the difference with merging all TABLE_YYYYMM together and then adding quantity to table A by ID and date variables ? &lt;BR /&gt;&lt;BR /&gt; data table;&lt;BR /&gt;   set table_:;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;Thank you very much for your help</description>
      <pubDate>Wed, 28 Sep 2022 18:52:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ADD-value-from-other-tables/m-p/835692#M330408</guid>
      <dc:creator>elsfy</dc:creator>
      <dc:date>2022-09-28T18:52:57Z</dc:date>
    </item>
    <item>
      <title>Re: ADD value from other tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ADD-value-from-other-tables/m-p/835699#M330409</link>
      <description>Thank you !&lt;BR /&gt;Will give more detail when i can. I can say that date value is written as a numeric variable YYYYMM and datasets Table_YYYYMM have more than one record.&lt;BR /&gt;Just a question here it comes back to merging tables if i am correct (Example_ datasets equiv. to Table_YYYYMM) and then matching with the base dataset (dataset A in my case) by ID and date. No? Isn’t there a way without combining datasets?</description>
      <pubDate>Wed, 28 Sep 2022 19:10:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ADD-value-from-other-tables/m-p/835699#M330409</guid>
      <dc:creator>elsfy</dc:creator>
      <dc:date>2022-09-28T19:10:51Z</dc:date>
    </item>
    <item>
      <title>Re: ADD value from other tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ADD-value-from-other-tables/m-p/835701#M330410</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;I think this was merged or added to a different posts by accident?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes, and I don't know how.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Sep 2022 19:44:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ADD-value-from-other-tables/m-p/835701#M330410</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-09-28T19:44:01Z</dc:date>
    </item>
  </channel>
</rss>

