<?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: Create final dataset even if one of the source dataset don't exists in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-final-dataset-even-if-one-of-the-source-dataset-don-t/m-p/605368#M175688</link>
    <description>&lt;P&gt;See this thread&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Procedures/Include-dataset-in-SET-statement-only-if-it-exists/td-p/391725" target="_blank"&gt;https://communities.sas.com/t5/SAS-Procedures/Include-dataset-in-SET-statement-only-if-it-exists/td-p/391725&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 19 Nov 2019 12:01:57 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2019-11-19T12:01:57Z</dc:date>
    <item>
      <title>Create final dataset even if one of the source dataset don't exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-final-dataset-even-if-one-of-the-source-dataset-don-t/m-p/605363#M175686</link>
      <description>&lt;P&gt;I want to create WANT dataset as mentioned below although if one of source dataset don't exist. I tried the code below but it is not working. In real life HAVE1 dataset exist for sure with some data but HAVE2 dataset will not exist all the time. HAVE1 and HAVE2 dataset will be in same structure.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I want to dynamically write one code similar to the one mentioned below to create WANT dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have1;
	id=1;
	output;
run;

/*create dataset want even if have2 dataset don't exist*/
data want;
	set have1 have2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;log:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;26         data have1;
27         id=1;
28         output;
29         run;

NOTE: Compression was disabled for data set WORK.HAVE1 because compression overhead would increase the size of the data set.
NOTE: The data set WORK.HAVE1 has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds
      

30         
31         /*create dataset want even if have2 dataset don't exist*/
32         
33         data want;
34         set have1 have2;
ERROR: File WORK.HAVE2.DATA does not exist.
35         run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Nov 2019 11:46:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-final-dataset-even-if-one-of-the-source-dataset-don-t/m-p/605363#M175686</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2019-11-19T11:46:25Z</dc:date>
    </item>
    <item>
      <title>Re: Create final dataset even if one of the source dataset don't exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-final-dataset-even-if-one-of-the-source-dataset-don-t/m-p/605368#M175688</link>
      <description>&lt;P&gt;See this thread&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Procedures/Include-dataset-in-SET-statement-only-if-it-exists/td-p/391725" target="_blank"&gt;https://communities.sas.com/t5/SAS-Procedures/Include-dataset-in-SET-statement-only-if-it-exists/td-p/391725&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2019 12:01:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-final-dataset-even-if-one-of-the-source-dataset-don-t/m-p/605368#M175688</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-11-19T12:01:57Z</dc:date>
    </item>
    <item>
      <title>Re: Create final dataset even if one of the source dataset don't exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-final-dataset-even-if-one-of-the-source-dataset-don-t/m-p/605369#M175689</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you have common prefix you could try:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have: ;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;all the best&lt;/P&gt;&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2019 12:02:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-final-dataset-even-if-one-of-the-source-dataset-don-t/m-p/605369#M175689</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2019-11-19T12:02:07Z</dc:date>
    </item>
    <item>
      <title>Re: Create final dataset even if one of the source dataset don't exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-final-dataset-even-if-one-of-the-source-dataset-don-t/m-p/605370#M175690</link>
      <description>&lt;P&gt;Or if the list is "twisted", then you can do it like that:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  call execute('data want; set ');

  length set $ 41; drop set;
  do until (set = " ");
    i+1;
  	set = scan("have1 have2 ABC something.else", i);
    if exist(set) then call execute(set);
  end;
  call execute('; run;');

  stop;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All the best&lt;/P&gt;&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2019 12:21:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-final-dataset-even-if-one-of-the-source-dataset-don-t/m-p/605370#M175690</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2019-11-19T12:21:16Z</dc:date>
    </item>
    <item>
      <title>Re: Create final dataset even if one of the source dataset don't exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-final-dataset-even-if-one-of-the-source-dataset-don-t/m-p/605373#M175692</link>
      <description>&lt;P&gt;So can't we accomplish this task without querying the metadata?&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2019 12:54:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-final-dataset-even-if-one-of-the-source-dataset-don-t/m-p/605373#M175692</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2019-11-19T12:54:27Z</dc:date>
    </item>
    <item>
      <title>Re: Create final dataset even if one of the source dataset don't exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-final-dataset-even-if-one-of-the-source-dataset-don-t/m-p/605374#M175693</link>
      <description>&lt;P&gt;The simple method is this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set
  have1
%if %sysfunc(exist(have2)) %then %do;
  have2
%end;
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Nov 2019 13:02:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-final-dataset-even-if-one-of-the-source-dataset-don-t/m-p/605374#M175693</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-11-19T13:02:07Z</dc:date>
    </item>
    <item>
      <title>Re: Create final dataset even if one of the source dataset don't exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-final-dataset-even-if-one-of-the-source-dataset-don-t/m-p/605376#M175694</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think both, my and &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;'s, solutions are quite "without querying the metadata"-ish&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All the best&lt;/P&gt;&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2019 13:09:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-final-dataset-even-if-one-of-the-source-dataset-don-t/m-p/605376#M175694</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2019-11-19T13:09:54Z</dc:date>
    </item>
    <item>
      <title>Re: Create final dataset even if one of the source dataset don't exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-final-dataset-even-if-one-of-the-source-dataset-don-t/m-p/605384#M175701</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;one more would be:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have1;
	id=1;
	output;
run;

options NODSNFERR;

data want;
    set have1 have2;
run;

options DSNFERR;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All the best&lt;/P&gt;&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2019 13:25:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-final-dataset-even-if-one-of-the-source-dataset-don-t/m-p/605384#M175701</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2019-11-19T13:25:39Z</dc:date>
    </item>
  </channel>
</rss>

