<?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: variable selection : keep if exists in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/variable-selection-keep-if-exists/m-p/149252#M29471</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It worked, thanks a lot !&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 30 Oct 2014 13:08:35 GMT</pubDate>
    <dc:creator>Aboiron</dc:creator>
    <dc:date>2014-10-30T13:08:35Z</dc:date>
    <item>
      <title>variable selection : keep if exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/variable-selection-keep-if-exists/m-p/149248#M29467</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin: 0 0 1em; font-size: 14px; color: #000000; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; background: #ffffff;"&gt;I have several databases, one per geographical variables, that I want to append in the end. I am doing some data steps on them. As I have large databases, I select only the variables I need when I first call each table. But on tables in which one variable always equals 0, the variable is not in the table.&lt;/P&gt;&lt;P style="margin: 0 0 1em; font-size: 14px; color: #000000; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; background: #ffffff;"&gt;So when I select my (&lt;EM style="background: transparent;"&gt;keep=var&lt;/EM&gt;) in a for loop, it works fine if the variable exists, but it produces an error in the other case, so that these tables are ignored.&lt;/P&gt;&lt;PRE style="margin: 0 0 10px; padding: 5px; font-size: 14px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; color: #000000; background: #eeeeee;"&gt;
&lt;P&gt;&lt;CODE style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; background-position: initial;"&gt;do i=1 to 10 ; &lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; background-position: initial;"&gt;data temp; &lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; background-position: initial;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set area_i(keep= var1 var2); &lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; background-position: initial;"&gt;run; &lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; background-position: initial;"&gt;proc append base=want &lt;/CODE&gt;&lt;SPAN style="line-height: 1.5em;"&gt;data=temp force; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="line-height: 1.5em;"&gt;run; &lt;/SPAN&gt;&lt;/P&gt;
&lt;/PRE&gt;&lt;P style="margin: 0 0 1em; font-size: 14px; color: #000000; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; background: #ffffff;"&gt;Is there a simple way to tackle that ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2014 12:31:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/variable-selection-keep-if-exists/m-p/149248#M29467</guid>
      <dc:creator>Aboiron</dc:creator>
      <dc:date>2014-10-30T12:31:40Z</dc:date>
    </item>
    <item>
      <title>Re: variable selection : keep if exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/variable-selection-keep-if-exists/m-p/149249#M29468</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can suppress the generation of an ERROR with options nodsfnerr;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2014 12:42:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/variable-selection-keep-if-exists/m-p/149249#M29468</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2014-10-30T12:42:54Z</dc:date>
    </item>
    <item>
      <title>Re: variable selection : keep if exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/variable-selection-keep-if-exists/m-p/149250#M29469</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;DKRICOND=ERROR | WARN | WARNING | NOWARN &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DKROCOND=ERROR | WARN | WARNING | NOWARN &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2014 12:52:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/variable-selection-keep-if-exists/m-p/149250#M29469</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-10-30T12:52:51Z</dc:date>
    </item>
    <item>
      <title>Re: variable selection : keep if exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/variable-selection-keep-if-exists/m-p/149251#M29470</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could also create an empty template dataset, and set this with your data so the variables you require are never missing:&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table TEMPLATE (VAR1 char(200),VAR2 char(200));&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data temp (keep=var1 var2) ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set area_i template;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That way temp will always have var1 and var2.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2014 13:08:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/variable-selection-keep-if-exists/m-p/149251#M29470</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-10-30T13:08:06Z</dc:date>
    </item>
    <item>
      <title>Re: variable selection : keep if exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/variable-selection-keep-if-exists/m-p/149252#M29471</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It worked, thanks a lot !&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2014 13:08:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/variable-selection-keep-if-exists/m-p/149252#M29471</guid>
      <dc:creator>Aboiron</dc:creator>
      <dc:date>2014-10-30T13:08:35Z</dc:date>
    </item>
    <item>
      <title>Re: variable selection : keep if exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/variable-selection-keep-if-exists/m-p/149253#M29472</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am afraid it will add too much time, as it adds one dataset creation. I have millions of observations, so this might matters.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2014 13:09:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/variable-selection-keep-if-exists/m-p/149253#M29472</guid>
      <dc:creator>Aboiron</dc:creator>
      <dc:date>2014-10-30T13:09:52Z</dc:date>
    </item>
    <item>
      <title>Re: variable selection : keep if exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/variable-selection-keep-if-exists/m-p/149254#M29473</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I did not find any occurence of your option :smileyconfused:&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2014 13:10:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/variable-selection-keep-if-exists/m-p/149254#M29473</guid>
      <dc:creator>Aboiron</dc:creator>
      <dc:date>2014-10-30T13:10:25Z</dc:date>
    </item>
    <item>
      <title>Re: variable selection : keep if exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/variable-selection-keep-if-exists/m-p/149255#M29474</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Brain fart. &lt;A href="https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000203285.htm" title="https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000203285.htm"&gt;SAS(R) 9.2 Language Reference: Dictionary, Fourth Edition&lt;/A&gt; describes it, but it is used to suppress errors caused by nonexisting datasets.&lt;/P&gt;&lt;P&gt;Xia Keshan has the correct solution.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2014 13:18:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/variable-selection-keep-if-exists/m-p/149255#M29474</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2014-10-30T13:18:00Z</dc:date>
    </item>
    <item>
      <title>Re: variable selection : keep if exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/variable-selection-keep-if-exists/m-p/149256#M29475</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry, I was going on the example you had given.&amp;nbsp; If you are dealing with large amount of datasets then you want a better way of working.&amp;nbsp; Check the metadata and then generate the program from that.&amp;nbsp; Whilst there are ways to get around warnings and such like, they do come out for a reason.&amp;nbsp; IMO I would try to fix these rather than remove them from the log.&amp;nbsp; E.g.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; distinct NAME&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; into&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; :TABLE1 separated by " "&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SASHELP.VCOLUMN&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LIBNAME="WORK"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and&amp;nbsp;&amp;nbsp;&amp;nbsp; MEMNAME="DATASET"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and&amp;nbsp;&amp;nbsp;&amp;nbsp; NAME in ("VAR1","VAR2");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; distinct NAME&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; into&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; :TABLE2 separated by " "&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SASHELP.VCOLUMN&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LIBNAME="WORK"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and&amp;nbsp;&amp;nbsp;&amp;nbsp; MEMNAME="DATASET"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and&amp;nbsp;&amp;nbsp;&amp;nbsp; NAME in ("VAR1","VAR2");&lt;/P&gt;&lt;P&gt;/* Note, probably easier ways to get the macro lists I am typing this quickly */&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set table1 (keep=id &amp;amp;table1.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; table2 (keep=id &amp;amp;table2.);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2014 13:22:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/variable-selection-keep-if-exists/m-p/149256#M29475</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-10-30T13:22:21Z</dc:date>
    </item>
  </channel>
</rss>

