<?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: Condition on dataset name in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Condition-on-dataset-name/m-p/835664#M330374</link>
    <description>Hi, &lt;BR /&gt;&lt;BR /&gt;Thanks. I replied to another comment being more specific about what i want to do.</description>
    <pubDate>Wed, 28 Sep 2022 16:08:40 GMT</pubDate>
    <dc:creator>elsfy</dc:creator>
    <dc:date>2022-09-28T16:08:40Z</dc:date>
    <item>
      <title>Condition on dataset name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Condition-on-dataset-name/m-p/835632#M330354</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Is there a way to select the right dataset based on a condition ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have many datasets with the same name but their suffix is different and i want to specify a condition just like that : "if dataset name contains XXX then select this dataset and add the variable from this dataset to another dataset "&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Sep 2022 15:10:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Condition-on-dataset-name/m-p/835632#M330354</guid>
      <dc:creator>elsfy</dc:creator>
      <dc:date>2022-09-28T15:10:07Z</dc:date>
    </item>
    <item>
      <title>Re: Condition on dataset name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Condition-on-dataset-name/m-p/835647#M330367</link>
      <description>&lt;P&gt;I is not clear to me where you need to do this.&amp;nbsp; In a data step this example might be helpful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;44         data all;
45            set data: indsname=dsname;
46            if find(dsname,'02') then putlog 'NOTE: 02 ' dsname=;
47            run;

NOTE: 02 dsname=WORK.DATA02
NOTE: 02 dsname=WORK.DATA02
NOTE: There were 2 observations read from the data set WORK.DATA01.
NOTE: There were 2 observations read from the data set WORK.DATA02.
NOTE: There were 2 observations read from the data set WORK.DATA03.
NOTE: The data set WORK.ALL has 6 observations and 5 variables.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Sep 2022 15:38:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Condition-on-dataset-name/m-p/835647#M330367</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2022-09-28T15:38:56Z</dc:date>
    </item>
    <item>
      <title>Re: Condition on dataset name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Condition-on-dataset-name/m-p/835658#M330372</link>
      <description>&lt;P&gt;Have you considered using the dictionary tables in SAS to assign your table to a macro variable which could then be used in subsequent DATA steps or other procedures. This is a simple example about how to use one of those tables.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data test_001;
input x y @@;
cards;
1 2 3 4 5 6 7 8 9 10
;
run;
data test_002;
input x y @@;
cards;
11 12 13 14 15 16 17 18 19 20
;
run;

proc sql;
   select memname into: dsn
   from dictionary.tables
   where substr(memname, 6,3) = '001';
   quit;
/*You can see that &amp;amp;dsn is now a macro variable for the selected table*/
%put &amp;amp;=dsn;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Sep 2022 15:56:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Condition-on-dataset-name/m-p/835658#M330372</guid>
      <dc:creator>svh</dc:creator>
      <dc:date>2022-09-28T15:56:48Z</dc:date>
    </item>
    <item>
      <title>Re: Condition on dataset name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Condition-on-dataset-name/m-p/835662#M330373</link>
      <description>&lt;P&gt;Hey,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you. Let me be more specific about my request ; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a dataset called A like this :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ID&amp;nbsp;&amp;nbsp;&amp;nbsp; year&lt;/P&gt;
&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2013&lt;/P&gt;
&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2015&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;I need to add for each ID, a variable "quantity". Yet, this variable is in different datasets based on the year date : I have datasets with the year in their name B_2010, B_2011,B_2013,...&lt;/P&gt;
&lt;P&gt;These datasets B_year are like this :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ID quantity&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; 553&lt;/P&gt;
&lt;P&gt;2&amp;nbsp; 789&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;I want this in dataset A :&lt;/P&gt;
&lt;P&gt;ID&amp;nbsp;&amp;nbsp;&amp;nbsp; year&amp;nbsp;&amp;nbsp;&amp;nbsp; quantity&lt;/P&gt;
&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2013&amp;nbsp;&amp;nbsp; 553&lt;/P&gt;
&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2015&amp;nbsp;&amp;nbsp; 789&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;But how can i tell SAS to search the information in the right table ?&lt;/P&gt;
&lt;P&gt;My point is to not merge dataset B_2013, B_2015,... because i have many many tables depending on the year.&lt;/P&gt;
&lt;P&gt;Hope it's clear&lt;/P&gt;</description>
      <pubDate>Wed, 28 Sep 2022 16:06:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Condition-on-dataset-name/m-p/835662#M330373</guid>
      <dc:creator>elsfy</dc:creator>
      <dc:date>2022-09-28T16:06:40Z</dc:date>
    </item>
    <item>
      <title>Re: Condition on dataset name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Condition-on-dataset-name/m-p/835664#M330374</link>
      <description>Hi, &lt;BR /&gt;&lt;BR /&gt;Thanks. I replied to another comment being more specific about what i want to do.</description>
      <pubDate>Wed, 28 Sep 2022 16:08:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Condition-on-dataset-name/m-p/835664#M330374</guid>
      <dc:creator>elsfy</dc:creator>
      <dc:date>2022-09-28T16:08:40Z</dc:date>
    </item>
    <item>
      <title>Re: Condition on dataset name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Condition-on-dataset-name/m-p/835945#M330519</link>
      <description>In the example, the data set b_year has two values of "quantity" that are merged with two years (2013 and 2015).Does each b_year data set have values from multiple years or one year?</description>
      <pubDate>Thu, 29 Sep 2022 20:20:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Condition-on-dataset-name/m-p/835945#M330519</guid>
      <dc:creator>svh</dc:creator>
      <dc:date>2022-09-29T20:20:34Z</dc:date>
    </item>
    <item>
      <title>Re: Condition on dataset name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Condition-on-dataset-name/m-p/836058#M330584</link>
      <description>&lt;P&gt;I would combine all B datasets and add the year, the dataset will then look like your final A dataset. Then you can do something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want_a;
  set a;
  if _n_ = 1 then do;
    declare hash h(dataset: "big_b");
    h.defineKey("id", "year");
    h.defineData("quantity");
    h.defineDone();
  end;

  rc = h.find();
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 30 Sep 2022 13:00:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Condition-on-dataset-name/m-p/836058#M330584</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-09-30T13:00:25Z</dc:date>
    </item>
  </channel>
</rss>

