<?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: Data Set options in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Data-Set-options/m-p/352016#M82019</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;


data b;
 set sashelp.class;
 stop;
run;

data a;
 set sashelp.class;
run;

data a(repempty=no);
 set b;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 21 Apr 2017 04:04:50 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2017-04-21T04:04:50Z</dc:date>
    <item>
      <title>Data Set options</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Set-options/m-p/351853#M81941</link>
      <description>&lt;P&gt;I like to copy data from one dataset to another example from dataset B to dataset A but if there are 0 zero records in dataset B it should not overwrite dataset A. &amp;nbsp;Is there any where clause option I can add in the set option to check &amp;nbsp;this. Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data A;&lt;/P&gt;&lt;P&gt;set B;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2017 19:16:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Set-options/m-p/351853#M81941</guid>
      <dc:creator>Melvin_Sas</dc:creator>
      <dc:date>2017-04-20T19:16:17Z</dc:date>
    </item>
    <item>
      <title>Re: Data Set options</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Set-options/m-p/351879#M81962</link>
      <description>&lt;P&gt;You might be able to piece something together that works some of the time, using only a DATA step.&amp;nbsp; But the best solution would use macro language.&amp;nbsp; For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro replace (in=, out=);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; %local any_obs;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; %let any_obs=N;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; data _null_;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set &amp;amp;in;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput('any_obs', 'Y');&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; stop;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; %if &amp;amp;any_obs=Y %then %do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data &amp;amp;out;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set &amp;amp;in;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; %end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%mend replace;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%replace (in=B, out=A)&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2017 19:35:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Set-options/m-p/351879#M81962</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-04-20T19:35:40Z</dc:date>
    </item>
    <item>
      <title>Re: Data Set options</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Set-options/m-p/351923#M81984</link>
      <description>&lt;P&gt;For your purpose, you could simply do:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data A;
	if n&amp;gt;0 then
		set B nobs=n;
	else set A;
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;However, there are things you need to be aware of:&lt;/P&gt;
&lt;P&gt;1.&amp;nbsp;All variables will show up&amp;nbsp;regardless&amp;nbsp;the source dataset&amp;nbsp;is copied&amp;nbsp;or not,&amp;nbsp;only their contents&amp;nbsp;will come in missing if not copied.&lt;/P&gt;
&lt;P&gt;2. When B is empty, instead of doing nothing, A is copied again.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2017 21:01:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Set-options/m-p/351923#M81984</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2017-04-20T21:01:18Z</dc:date>
    </item>
    <item>
      <title>Re: Data Set options</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Set-options/m-p/351934#M81992</link>
      <description>&lt;P&gt;Here is a method you can use. The first data _null_ step will test if there are any observations in B and set a macro varible to either CANCEL or spaces. &amp;nbsp;That way you can conditionally add the CANCEL keyword to the second data step's RUN statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  call symputx('cancel',ifc(eof,'cancel',''));
  stop;
  set b end=eof;
run;
data a;
  set b;
run &amp;amp;cancel;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Note that you will get a message in the log if you cancel the second step.&lt;/P&gt;
&lt;PRE&gt;1304  data a;
1305    set b;
1306  run &amp;amp;cancel;

WARNING: DATA step not executed at user's request.&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Apr 2017 22:05:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Set-options/m-p/351934#M81992</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-04-20T22:05:07Z</dc:date>
    </item>
    <item>
      <title>Re: Data Set options</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Set-options/m-p/351986#M82015</link>
      <description>&lt;P&gt;I would do this thus:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;_null_&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&amp;nbsp;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; B (obs=1)&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;call&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; execute(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'proc datasets lib=WORK noprint; age B A; run;'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;); &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The second statement is only executed if an observation can be read in B.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Renaming with proc datasets is much faster than copying a whole data set all over again, and conserves whatever attributes table B had (sortedby flag, index, compression, etc).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2017 02:57:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Set-options/m-p/351986#M82015</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2017-04-21T02:57:03Z</dc:date>
    </item>
    <item>
      <title>Re: Data Set options</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Set-options/m-p/352016#M82019</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;


data b;
 set sashelp.class;
 stop;
run;

data a;
 set sashelp.class;
run;

data a(repempty=no);
 set b;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Apr 2017 04:04:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Set-options/m-p/352016#M82019</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-04-21T04:04:50Z</dc:date>
    </item>
  </channel>
</rss>

