<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Statskom</title>
	<atom:link href="http://statskom.com/tag/error-variable-x-not-found/feed/" rel="self" type="application/rss+xml" />
	<link>http://statskom.com</link>
	<description>Clinical programming</description>
	<lastBuildDate>Thu, 05 Oct 2017 09:04:02 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=3.8.41</generator>
	<item>
		<title>SAS tips &amp; tricks #10 &#8211; ERROR: Variable X not found.</title>
		<link>http://statskom.com/sas-tips-tricks-10-error-variable-x-not-found/</link>
		<comments>http://statskom.com/sas-tips-tricks-10-error-variable-x-not-found/#comments</comments>
		<pubDate>Sun, 12 Oct 2014 17:49:03 +0000</pubDate>
		<dc:creator><![CDATA[Andrew N]]></dc:creator>
				<category><![CDATA[SAS Tips & Tricks]]></category>
		<category><![CDATA[ERROR: Variable X not found]]></category>
		<category><![CDATA[SAS errors]]></category>
		<category><![CDATA[SAS notes]]></category>
		<category><![CDATA[sas tips and tricks]]></category>
		<category><![CDATA[SAS warnings]]></category>

		<guid isPermaLink="false">http://statskom.com/?p=451</guid>
		<description><![CDATA[<p>In SAS tips &#38; tricks #9, we looked at what happens when SAS encounters an uninitialized variable within a DATA Step. Here we look at the possibly more serious scenario of what happens when SAS cannot find a reqruied variable&#8230; </p><p>The post <a rel="nofollow" href="http://statskom.com/sas-tips-tricks-10-error-variable-x-not-found/">SAS tips &#038; tricks #10 &#8211; ERROR: Variable X not found.</a> appeared first on <a rel="nofollow" href="http://statskom.com">Statskom</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>In <a title="SAS tips &amp; tricks #9 – NOTE: Variable X is uninitialized." href="http://statskom.com/sas-tips-tricks-9-note-variable-x-is-uninitialized/">SAS tips &amp; tricks #9</a>, we looked at what happens when SAS encounters an uninitialized variable within a DATA Step. Here we look at the possibly more serious scenario of what happens when SAS cannot find a reqruied variable within a PROC Step. You will usually notice that this has happened because the log will display the following message:</p>
<p><strong>&#8220;ERROR: Variable X not found&#8221; </strong></p>
<h2>What causes the message?</h2>
<p>This message occurs when a PROC Step  attempts to use a variable which is not present in the input dataset. This usually happens if, the variable was dropped or not kept in a preceding step, or if the code to create it has been accidentally omitted, or code has been copied from one place to another without making the necessary alterations.</p>
<h2>What happens when this occurs?</h2>
<p>When SAS cannot find a variable within a PROC Step, SAS will:</p>
<ul>
<li>outputs a message to a log stating the name of the variable(s) it cannot find, e.g. &#8220;<strong>ERROR: Variable X not found&#8221; </strong>implying that the variable X  is not present in the input dataset.</li>
<li>stop the execution of the current PROC Step and not produce any output.</li>
</ul>
<p>You will notice that SAS&#8217; behavior here is different to uninitialized variables in DATA Steps as in that instance it continues to create the output dataset.</p>
<h2>How to resolve it?</h2>
<p>To resolve this issue, ensure that the <em>not found</em> variable is available in the input dataset to the PROC Step, or udpate the PROC Step so that it does not require the <em>not found </em>variable in order to execute.</p>
<h3><span style="font-size: 1.5em; line-height: 1.5em;">Example</span></h3>
<p>The following code attempts to sort the SASHELP.CLASS dataset by the variables AGE, BSA and BMI variables.</p>
<pre>PROC SORT DATA = sashelp.class OUT=class;
  BY age bsa bmi;
RUN;</pre>
<p>This code results in the following messages being printed to the log.:</p>
<pre> 
 43         PROC SORT DATA = sashelp.class OUT=class;
 44           BY age bsa bmi;
 ERROR: Variable BSA not found.
 ERROR: Variable BMI not found.
 45         RUN;

 NOTE: The SAS System stopped processing this step because of errors.
 WARNING: The data set WORK.CLASS may be incomplete.  When this step was stopped there were 0 observations and 0 variables.</pre>
<p>The lines:</p>
<pre>ERROR: Variable BSA not found.
ERROR: Variable BMI not found.</pre>
<p>Tell us that the BSA and BMI variables respectively were not present in the dataset SASHELP.CLASS.</p>
<p>While the line:</p>
<pre> 
WARNING: The data set WORK.CLASS may be incomplete.  When this step was stopped there were 0 observations and 0 variables.</pre>
<p>Tells us that as a result of the error, the output dataset was not created.<br />
To resolve this issue, either the BSA and BMI  variables should be present in the input dataset or else they should be removed from the PROC Step.</p>
<p>For example, here we use a DATA Step to first derive the BSA variable and then remove the BMI variable from the PROC SORT:</p>
<pre>DATA class;
  SET sashelp.class;
  bsa = ((height *weight )/ 3131 )**1/2;
RUN;

PROC SORT DATA = class OUT=class2;
  BY age bsa ;
RUN;</pre>
<p>&nbsp;</p>
<p>The post <a rel="nofollow" href="http://statskom.com/sas-tips-tricks-10-error-variable-x-not-found/">SAS tips &#038; tricks #10 &#8211; ERROR: Variable X not found.</a> appeared first on <a rel="nofollow" href="http://statskom.com">Statskom</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://statskom.com/sas-tips-tricks-10-error-variable-x-not-found/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
