<?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: Possible to conditionally add variable based on obs from different datasets in set statement? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Possible-to-conditionally-add-variable-based-on-obs-from/m-p/292376#M60681</link>
    <description>&lt;P&gt;Both options work perfectly, thanks for the quick reply!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 18 Aug 2016 07:53:11 GMT</pubDate>
    <dc:creator>Kristiaan</dc:creator>
    <dc:date>2016-08-18T07:53:11Z</dc:date>
    <item>
      <title>Possible to conditionally add variable based on obs from different datasets in set statement?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Possible-to-conditionally-add-variable-based-on-obs-from/m-p/292371#M60678</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I havn't been able to google/find this issue, therefore this post.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have1 have2 have3;
length Source $5;
&lt;BR /&gt;where something = &amp;amp;a_variable.;&lt;BR /&gt;
if [observations are from have1] then Source="have1";
if [observations are from have2] then Source="have2";
if [observations are from have3] then Source="have3";

run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Is something like this possible? In the log it always shows how many observations SAS is able to find from the different datasets put in the set statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NOTE: There were 27834 observations read from the data set WORK.HAVE1.&lt;BR /&gt;NOTE: There were 0 observations read from the data set WORK.&lt;SPAN&gt;HAVE2&lt;/SPAN&gt;.&lt;BR /&gt;NOTE: There were 22808 observations read from the data set WORK.&lt;SPAN&gt;HAVE3&lt;/SPAN&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is it also possible to conditionally do something based on those observations? Like add a variable with the source of the obs? I am running SAS 9.4.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2016 07:32:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Possible-to-conditionally-add-variable-based-on-obs-from/m-p/292371#M60678</guid>
      <dc:creator>Kristiaan</dc:creator>
      <dc:date>2016-08-18T07:32:07Z</dc:date>
    </item>
    <item>
      <title>Re: Possible to conditionally add variable based on obs from different datasets in set statement?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Possible-to-conditionally-add-variable-based-on-obs-from/m-p/292373#M60679</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set
  have1 (in=have1)
  have2 (in=have2)
  have3 (in=have3)
;
length Source $5;
where something = &amp;amp;a_variable.;
if have1 then Source="have1";
if have2 then Source="have2";
if have3 then Source="have3";
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Aug 2016 07:35:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Possible-to-conditionally-add-variable-based-on-obs-from/m-p/292373#M60679</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-08-18T07:35:37Z</dc:date>
    </item>
    <item>
      <title>Re: Possible to conditionally add variable based on obs from different datasets in set statement?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Possible-to-conditionally-add-variable-based-on-obs-from/m-p/292374#M60680</link>
      <description>&lt;P&gt;INDSNAME option on the SET statement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See example 12 in the documentation, which is exactly your question.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lestmtsref/68024/HTML/default/viewer.htm#p00hxg3x8lwivcn1f0e9axziw57y.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lestmtsref/68024/HTML/default/viewer.htm#p00hxg3x8lwivcn1f0e9axziw57y.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2016 07:35:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Possible-to-conditionally-add-variable-based-on-obs-from/m-p/292374#M60680</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-08-18T07:35:44Z</dc:date>
    </item>
    <item>
      <title>Re: Possible to conditionally add variable based on obs from different datasets in set statement?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Possible-to-conditionally-add-variable-based-on-obs-from/m-p/292376#M60681</link>
      <description>&lt;P&gt;Both options work perfectly, thanks for the quick reply!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2016 07:53:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Possible-to-conditionally-add-variable-based-on-obs-from/m-p/292376#M60681</guid>
      <dc:creator>Kristiaan</dc:creator>
      <dc:date>2016-08-18T07:53:11Z</dc:date>
    </item>
  </channel>
</rss>

