<?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-errors/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 #9 &#8211; NOTE: Variable X is uninitialized.</title>
		<link>http://statskom.com/sas-tips-tricks-9-note-variable-x-is-uninitialized/</link>
		<comments>http://statskom.com/sas-tips-tricks-9-note-variable-x-is-uninitialized/#comments</comments>
		<pubDate>Thu, 09 Oct 2014 18:07:22 +0000</pubDate>
		<dc:creator><![CDATA[Andrew N]]></dc:creator>
				<category><![CDATA[SAS Tips & Tricks]]></category>
		<category><![CDATA[NOTE: Variable X is uninitialized.]]></category>
		<category><![CDATA[SAS errors]]></category>
		<category><![CDATA[sas naotes]]></category>
		<category><![CDATA[sas tips and tricks]]></category>
		<category><![CDATA[SAS warnings]]></category>

		<guid isPermaLink="false">http://statskom.com/?p=440</guid>
		<description><![CDATA[<p>The &#8220;NOTE: Variable X is uninitialized&#8221; message is a result of trying to run a DATA Step which utilizes a variable that is not present in the input dataset or has not been created at the point within the DATA&#8230; </p><p>The post <a rel="nofollow" href="http://statskom.com/sas-tips-tricks-9-note-variable-x-is-uninitialized/">SAS tips &#038; tricks #9 &#8211; NOTE: Variable X is uninitialized.</a> appeared first on <a rel="nofollow" href="http://statskom.com">Statskom</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>The &#8220;NOTE: Variable X is uninitialized&#8221; message is a result of trying to run a DATA Step which utilizes a variable that is not present in the input dataset or has not been created at the point within the DATA Step where SAS tries to utilize the variable.</p>
<h2>What causes the message?</h2>
<p>This message occurs when a DATA Step  attempts to use a variable which is either not present in the input dataset or has not been created in a preceding step. For example, if the variable was drop or not kept in in the input dataset, or if the code to create it has been accidentally omitted.</p>
<h2>What happens when this occurs?</h2>
<p>When SAS encounters an uninitialized variable within a DATA Step, SAS will:</p>
<ul>
<li>outputs a message to a log stating the name of the uninitialized variable.</li>
<li>set the uninitialized variable to missing, i.e. create a null numeric variable.</li>
<li>continue to create the output dataset.</li>
</ul>
<h2>How to resolve it?</h2>
<p>To resolve this issue, ensure that the uninitialized variable is available in your dataset at the point at which it is first required.</p>
<h3><span style="font-size: 1.5em; line-height: 1.5em;">Example</span></h3>
<p>The following code reads the SASHELP.CLASS dataset and attempts to create a new variable BSA_GRP, based on the value of a variable BSA:</p>
<pre>DATA class;
  SET sashelp.class;
  IF bsa &gt; 1 THEN bsa_grp = 1;
  ELSE IF bsa&gt; 1 THEN bsa_grp = 2;
RUN;</pre>
<p>This code results in the following messages being printed to the log.:</p>
<pre> NOTE: Variable bsa is uninitialized.
 NOTE: There were 19 observations read from the data set SASHELP.CLASS.
 NOTE: The data set WORK.CLASS has 19 observations and 7 variables.</pre>
<p>The first line tells us that the variable BSA was uninitialized (not available) at the point in the DATA Step where it was first required. The remaining lines tell us that despite the uninitialized variable, the dataset WORK.CLASS is still created.</p>
<p>We confirm this by opening the output dataset, which will be as follows:<br />
<a href="http://statskom.com/wp-content/uploads/2014/10/class.png"><img class="alignnone size-full wp-image-441" alt="class" src="http://statskom.com/wp-content/uploads/2014/10/class.png" width="1564" height="340" /></a></p>
<p>We see that SAS has created the output dataset, we also notice that it contains an empty numeric variable BSA.</p>
<p>To resolve this issue, either the BSA variable should be present in the input dataset or else it should be created in the current DATA Step prior to the statement in which the BSA variable is first used, for example:</p>
<pre>DATA class;
  SET sashelp.class;
  bsa = ((height *weight )/ 3131 )**1/2
  IF bsa &gt; 1 THEN bsa_grp = 1;
  ELSE IF bsa&gt; 1 THEN bsa_grp = 2;
RUN;</pre>
<p>The post <a rel="nofollow" href="http://statskom.com/sas-tips-tricks-9-note-variable-x-is-uninitialized/">SAS tips &#038; tricks #9 &#8211; NOTE: Variable X is uninitialized.</a> appeared first on <a rel="nofollow" href="http://statskom.com">Statskom</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://statskom.com/sas-tips-tricks-9-note-variable-x-is-uninitialized/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SAS tips &amp; tricks #8 &#8211; NOTE: Numeric values have been converted to charater values</title>
		<link>http://statskom.com/sas-tips-tricks-8-note-numeric-values-have-been-converted-to-character-values/</link>
		<comments>http://statskom.com/sas-tips-tricks-8-note-numeric-values-have-been-converted-to-character-values/#comments</comments>
		<pubDate>Tue, 16 Sep 2014 19:41:39 +0000</pubDate>
		<dc:creator><![CDATA[Andrew N]]></dc:creator>
				<category><![CDATA[SAS Tips & Tricks]]></category>
		<category><![CDATA[dirty data]]></category>
		<category><![CDATA[implicit data type conversion]]></category>
		<category><![CDATA[SAS errors]]></category>
		<category><![CDATA[sas naotes]]></category>
		<category><![CDATA[sas tips and tricks]]></category>
		<category><![CDATA[SAS warnings]]></category>

		<guid isPermaLink="false">http://statskom.com/?p=348</guid>
		<description><![CDATA[<p>In the last post SAS tips &#38; tricks #7 we looked at how to avoid implicit character to numeric conversion.  Here we look at what causes numeric to character implicit conversions and how to avoid them In a similar way&#8230; </p><p>The post <a rel="nofollow" href="http://statskom.com/sas-tips-tricks-8-note-numeric-values-have-been-converted-to-character-values/">SAS tips &#038; tricks #8 &#8211; NOTE: Numeric values have been converted to charater values</a> appeared first on <a rel="nofollow" href="http://statskom.com">Statskom</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>In the last post<a href="http://statskom.com/sas-tips-tricks-7-note-character-values-converted-numeric-values-places-given/"> SAS tips &amp; tricks #7 </a>we looked at how to avoid implicit character to numeric conversion.  Here we look at what causes numeric to character implicit conversions and how to avoid them</p>
<p><span style="font-size: 14px; line-height: 1.5em;">In a similar way to character to numeric implicit conversions, this  message occurs when you try to use a numeric variable in a function that requires a character argument, or to assign a numeric value to a variable which has already been defined as numeric.</span></p>
<p>It is possible to rely on SAS to perform these conversions imlpicitly, however, in general this is not considered good programming practice and it is usually preferable to perform these conversions explicitly. Implicit conversions also take more CPU time than explicit conversions and so may cause your program to execute more slowly.</p>
<p>Consider the following example, where we try to concatenate the character variable type with the numeric variable horsepower.</p>
<pre>DATA cars;
  SET sashelp.cars;
  type_horse = STRIP(type)!!"-"!!horsepower;
RUN;</pre>
<p>The output is created however the log displays the following message.</p>
<pre> 43         DATA cars;
 44           SET sashelp.cars;
 45           type_horse = STRIP(type)!!"-"!!horsepower;
 46         RUN;
NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).
       45:34</pre>
<p>This tells us that the code in line 45 of the log, at column 34 numeric variable has been used where a character variable was expected. In our case, the concatenation function (!!) expects a character variable, however horespower is numeric.</p>
<p>As the output dataset has been created, it may be tempting to leave the code as is, and have SAS perform the conversion for you. However, printing the dataset shows why this approach can be dangerous, as shown below.</p>
<div align="center">
<table border="0" cellspacing="0" cellpadding="0">
<thead>
<tr>
<td valign="bottom" width="52">
<p align="right"><b>Obs</b></p>
</td>
<td valign="bottom" width="159"><b> type_horse</b></td>
</tr>
</thead>
<tbody>
<tr>
<td valign="top" width="52">
<p align="right"><b>1</b></p>
</td>
<td valign="top" width="159">SUV-         265</td>
</tr>
<tr>
<td valign="top" width="52">
<p align="right"><b>2</b></p>
</td>
<td valign="top" width="159">Sedan-         200</td>
</tr>
<tr>
<td valign="top" width="52">
<p align="right"><b>3</b></p>
</td>
<td valign="top" width="159">Sedan-         200</td>
</tr>
<tr>
<td valign="top" width="52">
<p align="right"><b>4</b></p>
</td>
<td valign="top" width="159">Sedan-         270</td>
</tr>
<tr>
<td valign="top" width="52">
<p align="right"><b>5</b></p>
</td>
<td valign="top" width="159">Sedan-         225</td>
</tr>
<tr>
<td valign="top" width="52">
<p align="right"><b>6</b></p>
</td>
<td valign="top" width="159">Sedan-         225</td>
</tr>
<tr>
<td valign="top" width="52">
<p align="right"><b>7</b></p>
</td>
<td valign="top" width="159">Sports-         290</td>
</tr>
</tbody>
</table>
</div>
<p>Note how instead of being concatenated directly onto the hyphen, the horsepower, there are many leading spaces prior to the digits. These leading spaces are created by the implicit data conversion. When SAS performs this implicit numeric to character conversion it must select the format to use when performing the conversion and the width of the converted string. By default, SAS uses a format of BEST12, since our horsepower values each contains three digits, it means that SAS pads the values with nine leading spaces when performing the concatenation.</p>
<p>This issue can be avoided by first using the PUT function to convert the values from numeric to character. As shown in the example below.</p>
<pre>DATA cars;
  SET sashelp.cars;
  type_horse = STRIP(type)!!"-"!!PUT(horsepower,3.);
RUN;</pre>
<p>The second argument of the PUT functions allows you to specify the format that should be used during the conversion. As the horsepower values all have three digits, we specify a format of 3., which means that the value of horsepower is written as a character string of three digits in the concatenation. This also removes the converted to warning message from the log.</p>
<p>Finally a prinnt of the dataset confirms that the leading spaces have indeed been removed.</p>
<div align="center">
<table border="0" cellspacing="0" cellpadding="0">
<thead>
<tr>
<td valign="bottom" width="52">
<p align="right"><b>Obs</b></p>
</td>
<td valign="bottom" width="117"><b>type_horse</b></td>
</tr>
</thead>
<tbody>
<tr>
<td valign="top" width="52">
<p align="right"><b>1</b></p>
</td>
<td valign="top" width="117">SUV-265</td>
</tr>
<tr>
<td valign="top" width="52">
<p align="right"><b>2</b></p>
</td>
<td valign="top" width="117">Sedan-200</td>
</tr>
<tr>
<td valign="top" width="52">
<p align="right"><b>3</b></p>
</td>
<td valign="top" width="117">Sedan-200</td>
</tr>
<tr>
<td valign="top" width="52">
<p align="right"><b>4</b></p>
</td>
<td valign="top" width="117">Sedan-270</td>
</tr>
<tr>
<td valign="top" width="52">
<p align="right"><b>5</b></p>
</td>
<td valign="top" width="117">Sedan-225</td>
</tr>
<tr>
<td valign="top" width="52">
<p align="right"><b>6</b></p>
</td>
<td valign="top" width="117">Sedan-225</td>
</tr>
</tbody>
</table>
</div>
<p>&nbsp;</p>
<p>The post <a rel="nofollow" href="http://statskom.com/sas-tips-tricks-8-note-numeric-values-have-been-converted-to-character-values/">SAS tips &#038; tricks #8 &#8211; NOTE: Numeric values have been converted to charater 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-8-note-numeric-values-have-been-converted-to-character-values/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SAS tips &amp; tricks #7 &#8211; NOTE: Character values have been converted to numeric values</title>
		<link>http://statskom.com/sas-tips-tricks-7-note-character-values-converted-numeric-values-places-given/</link>
		<comments>http://statskom.com/sas-tips-tricks-7-note-character-values-converted-numeric-values-places-given/#comments</comments>
		<pubDate>Thu, 04 Sep 2014 16:21:52 +0000</pubDate>
		<dc:creator><![CDATA[Andrew N]]></dc:creator>
				<category><![CDATA[SAS Tips & Tricks]]></category>
		<category><![CDATA[dirty data]]></category>
		<category><![CDATA[implicit data type conversion]]></category>
		<category><![CDATA[SAS errors]]></category>
		<category><![CDATA[sas naotes]]></category>
		<category><![CDATA[sas tips and tricks]]></category>
		<category><![CDATA[SAS warnings]]></category>

		<guid isPermaLink="false">http://statskom.com/?p=336</guid>
		<description><![CDATA[<p>In the last two posts we looked at how to clean the log by removing SAS NOTEs, here we look again at what to do when your log contains the following message: NOTE: Character values have been converted to numeric&#8230; </p><p>The post <a rel="nofollow" href="http://statskom.com/sas-tips-tricks-7-note-character-values-converted-numeric-values-places-given/">SAS tips &#038; tricks #7 &#8211; NOTE: Character values have been converted to numeric values</a> appeared first on <a rel="nofollow" href="http://statskom.com">Statskom</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>In the last two posts we looked at how to clean the log by removing SAS NOTEs, here we look again at what to do when your log contains the following message:</p>
<h3>NOTE: Character values have been converted to numeric values.</h3>
<p>This  message occurs when you try to perform a numeric calculation using a character variable, or to assign a character value to a variable which has already been defined as numeric.</p>
<p>It is possible to rely on SAS to perform these conversions imlpicitly, however, in general this is not considered good programming practice and it is usually preferable to perform these conversions explicitly. Implicit conversions also take more CPU time than explicit conversions and so may cause your program to execute more slowly.</p>
<p>Here we look at a few example where this implicit conversion is performed and look at ways in which the programs can be updated to avoid the NOTE.</p>
<p>Consider for example the following DATA step. A character variable WEIGHT_KG is created and assigned the value &#8220;75&#8243;, the subsequent statement attempts to use this character variable in a numeric calculation. In this instance SAS will perform an implicit conversion (i.e. SAS automatically converts the variable from character to numeric so that the calculation can take place). Here the character variable &#8220;75&#8243; is converted to a numeric variable and the statement executes giving the expected result, but writing a NOTE to the log explaining that SAS has had to perform an implicit conversion in order for the calculation to take place.</p>
<pre>DATA weight;
  weight_kg = "75";
  weigth_st = 0.157473 * weight_kg;
RUN;

NOTE: Character values have been converted to numeric values at the places given by:
      (Line):(Column).
      35:26</pre>
<p>To avoid the note being written to the log, you can explicitly perform the character to numeric conversion.</p>
<p>Going back to our example, this would involve using an INPUT function to convert the variable WEIGHT_KG to a numeric before the calculation takes place as follows:</p>
<pre>DATA weight;
  weight_kg = "75";
  weigth_st = 0.157473 * INPUT(weight_kg,BEST.);
RUN;</pre>
<p>Care should be taken with this approach however, in case the character variable contains values unsuitable for a numeric conversion. Consider the following example:</p>
<pre>DATA vitals;
  weight = "70.5";
  OUTPUT;
  weight = "U";
  OUTPUT;
RUN;

DATA vitals2;
  SET vitals;
  weight_rnd = ROUND(INPUT(weight,BEST.));
RUN;</pre>
<p>The second observation of this dataset would cause _ERROR_ variable to be set to 1 as the INPUT function tries to convert the character value &#8220;U&#8221; to a number. In this instance the log will show something similar to the following:</p>
<p>NOTE: Invalid argument to function INPUT at line 36 column 22. weight=U weight_rnd=. _ERROR_=1 _N_=2</p>
<p>Indicating that at observation 2 the variable WEIGHT contained a value &#8220;U&#8221; which was unsiotable for the INPUT function.</p>
<p>If the value of &#8220;U&#8221; is unexpected and perhaps indicates dirty data, then the best approach is usually to request that the input dataset is queried. If however the value is feasible, perhaps indicating that the test was not perofmed in this instance, then conditional programming can be used to indicate that the character to numeric conversion should only be performed on suitable input values, for example:</p>
<p>In the below example we use the ?? format modifier to first test to see whether the character variable contains a value which is suitable for conversion to a numeric, and then only perform the conversion if this is the case, otherwise a custom warning is written to the log indicating that the input data is not clean and that this should be investigated.</p>
<pre>DATA vitals2;
  SET vitals;
  IF  INPUT(weight,??BEST.) NE . THEN weight_rnd = ROUND(INPUT(weight,BEST.));
  ELSE IF weight NE "U" THEN PUT "WARN" "ING: the following non numeric values were found in the WEIGHT variable: " weight "at observation:" _n_;
RUN;</pre>
<p>&nbsp;</p>
<p>The post <a rel="nofollow" href="http://statskom.com/sas-tips-tricks-7-note-character-values-converted-numeric-values-places-given/">SAS tips &#038; tricks #7 &#8211; NOTE: Character values have been converted to numeric 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-7-note-character-values-converted-numeric-values-places-given/feed/</wfw:commentRss>
		<slash:comments>0</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>
