<?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: Drop/Keep errors in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Drop-Keep-errors/m-p/65571#M18702</link>
    <description>&lt;P&gt;There is an option for that, DKRICOND.&lt;BR /&gt; &lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
 782 data y2010(keep=a b c d) y2011(keep=a b);
 783 retain a b c d 0;
 784 run;

 NOTE: The data set WORK.Y2010 has 1 observations and 4 variables.
 NOTE: The data set WORK.Y2011 has 1 observations and 2 variables.
 NOTE: DATA statement used (Total process time):
 real time 0.01 seconds
cpu time 0.01 seconds


 785 proc options option=DKRICOND;
 786 run;

 SAS (r) Proprietary Software Release 9.2 TS2M0

 DKRICOND=ERROR Action for DROP/KEEP/RENAME error conditions on input SAS data sets
 NOTE: PROCEDURE OPTIONS used (Total process time):
 real time 0.03 seconds
cpu time 0.00 seconds


 787 data all;
 788 set
 789 y2010(keep=a b c d)
 790 y2011(keep=a b c d)
 791 ;
 ERROR: The variable c in the DROP, KEEP, or RENAME list has never been referenced.
 ERROR: The variable d in the DROP, KEEP, or RENAME list has never been referenced.
 792 run;

 NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.ALL may be incomplete. When this step was stopped there were 0 observations and 4 variables.
 WARNING: Data set WORK.ALL was not replaced because this step was stopped.
 NOTE: DATA statement used (Total process time):
 real time 0.01 seconds
cpu time 0.01 seconds


 793
 794 option DKRICOND=NOWARN;
 795 data all;
 796 set
 797 y2010(keep=a b c d)
 798 y2011(keep=a b c d)
 799 ;
 800 run;

 NOTE: There were 1 observations read from the data set WORK.Y2010.
 NOTE: There were 1 observations read from the data set WORK.Y2011.
 NOTE: The data set WORK.ALL has 2 observations and 4 variables.
 NOTE: DATA statement used (Total process time):
 real time 0.04 seconds
cpu time 0.01 seconds


 801 option DKRICOND=ERROR;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 24 Apr 2018 13:42:17 GMT</pubDate>
    <dc:creator>data_null__</dc:creator>
    <dc:date>2018-04-24T13:42:17Z</dc:date>
    <item>
      <title>Drop/Keep errors</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Drop-Keep-errors/m-p/65568#M18699</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I need to run the codes like below many times over. &lt;BR /&gt;
&lt;BR /&gt;
data abc;&lt;BR /&gt;
set abc (keep a b c d);&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
I have a lot of datasets like abc. Trouble is, I don't want to check every dataset that it has variable a, b, c, or d. In most cases, all the datasets have the same variables/columns such as the month when data is avaible. Sometimes, it doesn't have a variable, like when I collect yearly data for 2011 which doesn't have yearly data yet.&lt;BR /&gt;
&lt;BR /&gt;
When I run the program above, it gives errors like "variable d has never been referenced" and the result dataset has ZERO obs. &lt;BR /&gt;
&lt;BR /&gt;
My question: How can I run the program above even though the datast might not have variable "d", that is, the program keeps running and reading the data despite absence of variable "d"?</description>
      <pubDate>Fri, 13 May 2011 02:47:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Drop-Keep-errors/m-p/65568#M18699</guid>
      <dc:creator>smilingmelbourne</dc:creator>
      <dc:date>2011-05-13T02:47:44Z</dc:date>
    </item>
    <item>
      <title>Re: Drop/Keep errors</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Drop-Keep-errors/m-p/65569#M18700</link>
      <description>You could use something like:&lt;BR /&gt;
[pre]&lt;BR /&gt;
data have;&lt;BR /&gt;
  set sashelp.class (drop=height);&lt;BR /&gt;
run;&lt;BR /&gt;
proc sql noprint;&lt;BR /&gt;
  select name into :vars separated by " "&lt;BR /&gt;
    from dictionary.columns&lt;BR /&gt;
	  where libname eq "WORK" and&lt;BR /&gt;
	    memname="HAVE"&lt;BR /&gt;
		  and upcase(name) in ("AGE" "HEIGHT" "WEIGHT");&lt;BR /&gt;
  ;&lt;BR /&gt;
quit;&lt;BR /&gt;
%put &amp;amp;vars.;&lt;BR /&gt;
data want;&lt;BR /&gt;
  set have (keep=&amp;amp;vars.);&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
HTH,&lt;BR /&gt;
Art&lt;BR /&gt;
---------&lt;BR /&gt;
&amp;gt; Hi,&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; I need to run the codes like below many times over. &lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; data abc;&lt;BR /&gt;
&amp;gt; set abc (keep a b c d);&lt;BR /&gt;
&amp;gt; run;&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; I have a lot of datasets like abc. Trouble is, I&lt;BR /&gt;
&amp;gt; don't want to check every dataset that it has&lt;BR /&gt;
&amp;gt; variable a, b, c, or d. In most cases, all the&lt;BR /&gt;
&amp;gt; datasets have the same variables/columns such as the&lt;BR /&gt;
&amp;gt; month when data is avaible. Sometimes, it doesn't&lt;BR /&gt;
&amp;gt; have a variable, like when I collect yearly data for&lt;BR /&gt;
&amp;gt; 2011 which doesn't have yearly data yet.&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; When I run the program above, it gives errors like&lt;BR /&gt;
&amp;gt; "variable d has never been referenced" and the result&lt;BR /&gt;
&amp;gt; dataset has ZERO obs. &lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; My question: How can I run the program above even&lt;BR /&gt;
&amp;gt; though the datast might not have variable "d", that&lt;BR /&gt;
&amp;gt; is, the program keeps running and reading the data&lt;BR /&gt;
&amp;gt; despite absence of variable "d"?</description>
      <pubDate>Fri, 13 May 2011 03:09:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Drop-Keep-errors/m-p/65569#M18700</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-05-13T03:09:17Z</dc:date>
    </item>
    <item>
      <title>Re: Drop/Keep errors</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Drop-Keep-errors/m-p/65570#M18701</link>
      <description>Art.T is right.&lt;BR /&gt;
Every time before you run this code, you can execute the code offered by Art.T to check the variable list, and put this list where as Art.T do.&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Fri, 13 May 2011 10:19:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Drop-Keep-errors/m-p/65570#M18701</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-05-13T10:19:44Z</dc:date>
    </item>
    <item>
      <title>Re: Drop/Keep errors</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Drop-Keep-errors/m-p/65571#M18702</link>
      <description>&lt;P&gt;There is an option for that, DKRICOND.&lt;BR /&gt; &lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
 782 data y2010(keep=a b c d) y2011(keep=a b);
 783 retain a b c d 0;
 784 run;

 NOTE: The data set WORK.Y2010 has 1 observations and 4 variables.
 NOTE: The data set WORK.Y2011 has 1 observations and 2 variables.
 NOTE: DATA statement used (Total process time):
 real time 0.01 seconds
cpu time 0.01 seconds


 785 proc options option=DKRICOND;
 786 run;

 SAS (r) Proprietary Software Release 9.2 TS2M0

 DKRICOND=ERROR Action for DROP/KEEP/RENAME error conditions on input SAS data sets
 NOTE: PROCEDURE OPTIONS used (Total process time):
 real time 0.03 seconds
cpu time 0.00 seconds


 787 data all;
 788 set
 789 y2010(keep=a b c d)
 790 y2011(keep=a b c d)
 791 ;
 ERROR: The variable c in the DROP, KEEP, or RENAME list has never been referenced.
 ERROR: The variable d in the DROP, KEEP, or RENAME list has never been referenced.
 792 run;

 NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.ALL may be incomplete. When this step was stopped there were 0 observations and 4 variables.
 WARNING: Data set WORK.ALL was not replaced because this step was stopped.
 NOTE: DATA statement used (Total process time):
 real time 0.01 seconds
cpu time 0.01 seconds


 793
 794 option DKRICOND=NOWARN;
 795 data all;
 796 set
 797 y2010(keep=a b c d)
 798 y2011(keep=a b c d)
 799 ;
 800 run;

 NOTE: There were 1 observations read from the data set WORK.Y2010.
 NOTE: There were 1 observations read from the data set WORK.Y2011.
 NOTE: The data set WORK.ALL has 2 observations and 4 variables.
 NOTE: DATA statement used (Total process time):
 real time 0.04 seconds
cpu time 0.01 seconds


 801 option DKRICOND=ERROR;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 24 Apr 2018 13:42:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Drop-Keep-errors/m-p/65571#M18702</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2018-04-24T13:42:17Z</dc:date>
    </item>
  </channel>
</rss>

