<?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/sas-notes/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>
		<item>
		<title>SAS tips &amp; tricks #6 – NOTE: Missing values were generated as a result of performing an operation on missing values.</title>
		<link>http://statskom.com/sas-tips-tricks-6-note-missing-values-generated-result-performing-operation-missing-values/</link>
		<comments>http://statskom.com/sas-tips-tricks-6-note-missing-values-generated-result-performing-operation-missing-values/#comments</comments>
		<pubDate>Mon, 01 Sep 2014 18:06:33 +0000</pubDate>
		<dc:creator><![CDATA[Andrew N]]></dc:creator>
				<category><![CDATA[SAS Tips & Tricks]]></category>
		<category><![CDATA[MEAN]]></category>
		<category><![CDATA[NOTE: Missing values were generated as a result of performing an operation on missing values.]]></category>
		<category><![CDATA[SAS errors]]></category>
		<category><![CDATA[SAS notes]]></category>
		<category><![CDATA[SAS warnings]]></category>
		<category><![CDATA[SUM]]></category>

		<guid isPermaLink="false">http://statskom.com/?p=301</guid>
		<description><![CDATA[<p>In our last SAS tips &#38; tricks blog post (statskom.com/sas-tips-tricks-5-/) we looked at how to clean up the log by removing the &#8220;NOTE: Missing values were generated..&#8221; message. In this post we continue the theme by looking at another commonly&#8230; </p><p>The post <a rel="nofollow" href="http://statskom.com/sas-tips-tricks-6-note-missing-values-generated-result-performing-operation-missing-values/">SAS tips &#038; tricks #6 – NOTE: Missing values were generated as a result of performing an operation on missing values.</a> appeared first on <a rel="nofollow" href="http://statskom.com">Statskom</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>In our last SAS tips &amp; tricks blog post (<a title="statskom.com/sas-tips-tricks-4" href="http://statskom.com/sas-tips-tricks-4-note-query-specified-involves-ordering-item-doesnt-appear-select-clause/">statskom.com/sas-tips-tricks-5-/</a>) we looked at how to clean up the log by removing the &#8220;NOTE: Missing values were generated..&#8221; message. In this post we continue the theme by looking at another commonly occurring SAS message and how it can be resolved.</p>
<p>In this post we look at the SAS log message: &#8220;NOTE: Missing values were generated as a result of performing an operation on missing values.&#8221;, its causes and how to resolve it. This message is typically caused by attempting to perform a calculation on a numeric variable which is missing, its technical name is the propogation of missing values, since a missing input value causes a missing output value.</p>
<p>Consider the following vital signs data where we have three test results for pulse and two for heart rate.</p>
<pre>DATA vitals;
  ATTRIB pulse1 pulse2 pulse3 hr1 hr2 format = best.;
  INPUT pulse1 pulse2 pulse3 hr1 hr2;
INFILE cards;
DATALINES;
60 70 65 71 .
65 . 70 73 74
63 . . 72 73
65 77 73 74 75;
RUN;</pre>
<p>Notice that these test results are sometimes missing, now if we were to run a DATA Step similar to the below</p>
<pre>DATA vitals2;
  SET vitals;
  pulse_sum=pulse1+pulse2+pulse3;
  hr_sum = hr1 + hr2;
RUN;</pre>
<p>We would result in messages similar to the following being written to the SAS log:</p>
<p>79 DATA vitals2;<br />
80 SET vitals;<br />
81 pulse_sum=pulse1+pulse2+pulse3;<br />
82 hr_avg = (hr1 + hr2)/2;<br />
83 RUN;</p>
<p>NOTE: Missing values were generated as a result of performing an operation on missing values. Each place is given by: (Number of times) at (Line):(Column).  2 at 81:19 1 at 82:16</p>
<p>These messages tell you that the statement in line 81 of the log (81 pulse_sum=pulse1+pulse2+pulse3;) resulted in a missing values twice (2 at 81:19 )whereas the statement from line 82 (82 hr_avg = (hr1 + hr2;)/2 ) resulted in a missing value once (1 at 82:16) and a PROC PRINT of the results would show the following:</p>
<pre>Obs    pulse1    pulse2    pulse3    hr1   hr2    pulse_sum  hr_sum

1       60        70        65      71      .       195        .
2       65         .        70      73     74         .      73.5
3       63         .         .      72     73         .      72.5
4       65        77        73      74     75       215      74.5</pre>
<p>Note that as described in the log, the variable PULSE_SUM is missing twice (observations 2 and 3) whilse the HR_SUM variable is missing once (observation 1).</p>
<p>How you decide to deal with this message depends on whether you expect the variables in your input data to contain missing. If you do then you can omit missing values from your calculations by using the sample statistic functions. In this case we would use the MEAN and SUM functions as follows:</p>
<pre>DATA vitals2;
  SET vitals;
  pulse_sum=SUM(pulse1,pulse2,pulse3);
  hr_avg = MEAN(hr1,hr2);
RUN;</pre>
<p>Printing out the dataset gives the following:</p>
<pre>Obs    pulse1    pulse2    pulse3   hr1    hr2     pulse_sum  hr_avg

1       60        70        65      71      .       195      71.0
2       65         .        70      73     74       135      73.5
3       63         .         .      72     73        63      72.5
4       65        77        73      74     75       215      74.5</pre>
<p>Note that here PULSE_SUM is populated in every observation and is calculated as the sum of all available PULSE variables. HR_AVG is also populated in every observation and is calculated as the sum of all available HR variables divided by the number of available HR variables.</p>
<p>If however your data should not contain any missing values, then you could alternatively use the NMISS function to test whether your variables contain missing values and output a message to the log if they do.</p>
<p>More information on the mean and sum functions can be found in the <a href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000245860.htm">Functions and Call Routines </a>section of the SAS doc</p>
<p>&nbsp;</p>
<p>The post <a rel="nofollow" href="http://statskom.com/sas-tips-tricks-6-note-missing-values-generated-result-performing-operation-missing-values/">SAS tips &#038; tricks #6 – NOTE: Missing values were generated as a result of performing an operation on missing values.</a> appeared first on <a rel="nofollow" href="http://statskom.com">Statskom</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://statskom.com/sas-tips-tricks-6-note-missing-values-generated-result-performing-operation-missing-values/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
