<?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 How do I correct an &amp;quot;Invalid argument to sqrt&amp;quot; problem? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-do-I-correct-an-quot-Invalid-argument-to-sqrt-quot-problem/m-p/954871#M83834</link>
    <description>&lt;P&gt;I'm a first time user of the forum, have only recently returned to SASing, and am trying to get back in the saddle.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using SAS 9.2, I am attempting to compute a Body Roundness Index (BRI) from an anthropometric dataset.&amp;nbsp;&amp;nbsp; The BRI computation is broken down into three steps:&amp;nbsp; (1) Calculation of a waist to height ratio (WtHR), which expresses proportionality of waist circumference (waistcir) to stature (stature); (2) Calculation of eccentricity (Ecc), in which body shape is expressed in degrees of departure from an ellipse; and (3) Calculation of the BRI.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In order, the code entered is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;WtHR=round((waistcir/stature)*100, .1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ecc=sqrt(1-WtHR/3.14159)**2);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BRI=(364.2 - 365.5)*Ecc;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Running both Proc Print for screening, I've no problem with computed values for WtHR, but receive "." missing values for Ecc and BRI.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The system's objection is "Invalid argument to sqrt".&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is the problem one of syntax, or is it deeper?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 01 Jan 2025 22:32:40 GMT</pubDate>
    <dc:creator>GaryHeathcote</dc:creator>
    <dc:date>2025-01-01T22:32:40Z</dc:date>
    <item>
      <title>How do I correct an "Invalid argument to sqrt" problem?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-I-correct-an-quot-Invalid-argument-to-sqrt-quot-problem/m-p/954871#M83834</link>
      <description>&lt;P&gt;I'm a first time user of the forum, have only recently returned to SASing, and am trying to get back in the saddle.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using SAS 9.2, I am attempting to compute a Body Roundness Index (BRI) from an anthropometric dataset.&amp;nbsp;&amp;nbsp; The BRI computation is broken down into three steps:&amp;nbsp; (1) Calculation of a waist to height ratio (WtHR), which expresses proportionality of waist circumference (waistcir) to stature (stature); (2) Calculation of eccentricity (Ecc), in which body shape is expressed in degrees of departure from an ellipse; and (3) Calculation of the BRI.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In order, the code entered is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;WtHR=round((waistcir/stature)*100, .1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ecc=sqrt(1-WtHR/3.14159)**2);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BRI=(364.2 - 365.5)*Ecc;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Running both Proc Print for screening, I've no problem with computed values for WtHR, but receive "." missing values for Ecc and BRI.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The system's objection is "Invalid argument to sqrt".&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is the problem one of syntax, or is it deeper?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jan 2025 22:32:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-I-correct-an-quot-Invalid-argument-to-sqrt-quot-problem/m-p/954871#M83834</guid>
      <dc:creator>GaryHeathcote</dc:creator>
      <dc:date>2025-01-01T22:32:40Z</dc:date>
    </item>
    <item>
      <title>Re: How do I correct an "Invalid argument to sqrt" problem?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-I-correct-an-quot-Invalid-argument-to-sqrt-quot-problem/m-p/954873#M83835</link>
      <description>&lt;P&gt;What mathematically would be an invalid value to the SQRT function? This isn't really a SAS question, it's a math question. So even if you don't know SAS, but you know math, you should be able to come up with an answer.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jan 2025 22:47:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-I-correct-an-quot-Invalid-argument-to-sqrt-quot-problem/m-p/954873#M83835</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2025-01-01T22:47:24Z</dc:date>
    </item>
    <item>
      <title>Re: How do I correct an "Invalid argument to sqrt" problem?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-I-correct-an-quot-Invalid-argument-to-sqrt-quot-problem/m-p/954874#M83836</link>
      <description>Is WtHR ever &amp;gt;1?  If so, your equation for Ecc is going to generate a negative number, which you can't take the square root of.  That said, the way you've written the Ecc equation in your question has unbalanced parentheses (one open, 2 close) so I don't really know if the **2 is where it's supposed to be.</description>
      <pubDate>Wed, 01 Jan 2025 22:48:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-I-correct-an-quot-Invalid-argument-to-sqrt-quot-problem/m-p/954874#M83836</guid>
      <dc:creator>quickbluefish</dc:creator>
      <dc:date>2025-01-01T22:48:17Z</dc:date>
    </item>
    <item>
      <title>Re: How do I correct an "Invalid argument to sqrt" problem?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-I-correct-an-quot-Invalid-argument-to-sqrt-quot-problem/m-p/954877#M83837</link>
      <description>I think your code was not right.&lt;BR /&gt;Ecc=sqrt(1-WtHR/3.14159)**2);&lt;BR /&gt;You have unmatched parentheses . left is one but right is two. you should delete one of right.</description>
      <pubDate>Thu, 02 Jan 2025 01:10:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-I-correct-an-quot-Invalid-argument-to-sqrt-quot-problem/m-p/954877#M83837</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-01-02T01:10:45Z</dc:date>
    </item>
    <item>
      <title>Re: How do I correct an "Invalid argument to sqrt" problem?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-I-correct-an-quot-Invalid-argument-to-sqrt-quot-problem/m-p/954879#M83838</link>
      <description>&lt;P&gt;Best practice on this forum is any time you get a message in the log that you want to question that you provide the code and the message from the log. Copy the text from the log starting at the first line of the data step or procedure through the last line of &lt;STRONG&gt;all&lt;/STRONG&gt; the messages. Then on the forum open a text box on the forum using the &amp;lt;/&amp;gt; icon that appears above the main message window and paste the text and paste the text.&lt;/P&gt;
&lt;P&gt;As a minimum that removes any question as to the exact code that was submitted.&lt;/P&gt;
&lt;P&gt;An example providing what should be a valid value for the WtHr variable, if maybe not biologically plausible shows:&lt;/P&gt;
&lt;PRE&gt;1    data example;
2       Wthr = 1;
3       Ecc=sqrt(1-WtHR/3.14159)**2);
                                   -
                                   388
                                   200
                                   76
ERROR 388-185: Expecting an arithmetic operator.

ERROR 200-322: The symbol is not recognized and will be ignored.

ERROR 76-322: Syntax error, statement will be ignored.

4    run;

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.EXAMPLE may be incomplete.  When this step was
         stopped there were 0 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.05 seconds
      cpu time            0.03 seconds
&lt;/PRE&gt;
&lt;P&gt;Which clearly shows the code you posted is an error and SAS will not do much of anything in the way of output for ECC or any dependent variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jan 2025 01:50:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-I-correct-an-quot-Invalid-argument-to-sqrt-quot-problem/m-p/954879#M83838</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2025-01-02T01:50:15Z</dc:date>
    </item>
    <item>
      <title>Re: How do I correct an "Invalid argument to sqrt" problem?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-I-correct-an-quot-Invalid-argument-to-sqrt-quot-problem/m-p/954887#M83839</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/471899"&gt;@GaryHeathcote&lt;/a&gt;&amp;nbsp;and welcome to the SAS Support Communities!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/471899"&gt;@GaryHeathcote&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;WtHR=round((waistcir/stature)*100, .1);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ecc=sqrt(1-WtHR/3.14159)**2);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BRI=(364.2 - 365.5)*Ecc;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I agree with the other experts that you should first make sure your formulas are correct before implementing them in code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is possible that all three of the above formulas are incorrect: Comparing them to the similar three-step approach presented in the Wikipedia article&amp;nbsp;&lt;A href="https://en.wikipedia.org/wiki/Body_roundness_index" target="_blank" rel="noopener"&gt;Body roundness index&lt;/A&gt;,&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;your factor 100 in the first formula would make sense if&amp;nbsp;&lt;FONT face="courier new,courier"&gt;waistcir&lt;/FONT&gt;&amp;nbsp;was measured in meters and &lt;FONT face="courier new,courier"&gt;stature&lt;/FONT&gt; in centimeters. But is this really the case (and not vice versa)? If not, this would most likely cause the "Invalid argument to sqrt" problem (because then WtHR [which Wikipedia denotes WHtR] would tend to be way too large). The rounding unit &lt;FONT face="courier new,courier"&gt;.1&lt;/FONT&gt; should be checked, too: Rounding WHtR to tenths in the numeric example shown in the Wikipedia article would change the result quite significantly (from 2.47 to 3.36), which is probably not desirable.&lt;/LI&gt;
&lt;LI&gt;In the second formula the opening parenthesis after the minus sign is missing (as others have mentioned already).&lt;/LI&gt;
&lt;LI&gt;The parentheses in the third formula are definitely wrong and must be removed. (As posted, the BRI would always be negative and the formula could obviously be simplified.)&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Thu, 02 Jan 2025 09:56:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-I-correct-an-quot-Invalid-argument-to-sqrt-quot-problem/m-p/954887#M83839</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2025-01-02T09:56:57Z</dc:date>
    </item>
    <item>
      <title>Re: How do I correct an "Invalid argument to sqrt" problem?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-I-correct-an-quot-Invalid-argument-to-sqrt-quot-problem/m-p/954890#M83840</link>
      <description>Thank you. In fact, I did eliminate the close parentheses on the right in&lt;BR /&gt;my last unsuccessful SAS run. My posting erred in that regard.&lt;BR /&gt;Apologies (to all) for that confusion.&lt;BR /&gt;</description>
      <pubDate>Thu, 02 Jan 2025 11:07:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-I-correct-an-quot-Invalid-argument-to-sqrt-quot-problem/m-p/954890#M83840</guid>
      <dc:creator>GaryHeathcote</dc:creator>
      <dc:date>2025-01-02T11:07:12Z</dc:date>
    </item>
    <item>
      <title>Re: How do I correct an "Invalid argument to sqrt" problem?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-I-correct-an-quot-Invalid-argument-to-sqrt-quot-problem/m-p/954899#M83842</link>
      <description>&lt;P&gt;It's possible the correct formula for Ecc just involves squaring the inner part (thus guaranteeing a positive number) &lt;EM&gt;before&lt;/EM&gt; taking the square root, in other words, the just taking the absolute value, though not sure it wouldn't just be written with absolute value notation if that were the case.&amp;nbsp; Like this (line breaks and spaces added for emphasis):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Ecc=sqrt(
&amp;nbsp; &amp;nbsp;( 1-WtHR/3.14159 )**2
&amp;nbsp; &amp;nbsp;);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Jan 2025 14:13:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-I-correct-an-quot-Invalid-argument-to-sqrt-quot-problem/m-p/954899#M83842</guid>
      <dc:creator>quickbluefish</dc:creator>
      <dc:date>2025-01-02T14:13:00Z</dc:date>
    </item>
    <item>
      <title>Re: How do I correct an "Invalid argument to sqrt" problem?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-I-correct-an-quot-Invalid-argument-to-sqrt-quot-problem/m-p/954915#M83847</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/223320"&gt;@quickbluefish&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;It's possible the correct formula for Ecc just involves squaring the inner part (thus guaranteeing a positive number) &lt;EM&gt;before&lt;/EM&gt; taking the square root, in other words, the just taking the absolute value, though not sure it wouldn't just be written with absolute value notation if that were the case.&amp;nbsp;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This &lt;EM&gt;would&lt;/EM&gt; be "possible" (albeit unusual) &lt;EM&gt;if&lt;/EM&gt; we knew nothing about the context of the formula. But the corresponding formula in the &lt;A href="https://en.wikipedia.org/wiki/Body_roundness_index" target="_blank" rel="noopener"&gt;Wikipedia article&lt;/A&gt;&amp;nbsp;and its explanation clearly show that an opening parenthesis must be inserted after the minus sign:&lt;/P&gt;
&lt;PRE&gt;&lt;FONT size="4"&gt;Ecc=sqrt(1-&lt;STRONG&gt;&lt;FONT color="#00FF88"&gt;(&lt;/FONT&gt;&lt;/STRONG&gt;WtHR/3.14159)**2);&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;Only this correction fits the definition of the eccentricity of an ellipse in geometry: see the first table in Wikipedia article&amp;nbsp;&lt;A href="https://en.wikipedia.org/wiki/Eccentricity_(mathematics)" target="_blank" rel="noopener"&gt;Eccentricity (mathematics)&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jan 2025 15:55:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-I-correct-an-quot-Invalid-argument-to-sqrt-quot-problem/m-p/954915#M83847</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2025-01-02T15:55:38Z</dc:date>
    </item>
    <item>
      <title>Re: How do I correct an "Invalid argument to sqrt" problem?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-I-correct-an-quot-Invalid-argument-to-sqrt-quot-problem/m-p/954918#M83850</link>
      <description>Thank makes sense!</description>
      <pubDate>Thu, 02 Jan 2025 16:07:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-I-correct-an-quot-Invalid-argument-to-sqrt-quot-problem/m-p/954918#M83850</guid>
      <dc:creator>quickbluefish</dc:creator>
      <dc:date>2025-01-02T16:07:04Z</dc:date>
    </item>
    <item>
      <title>Re: How do I correct an "Invalid argument to sqrt" problem?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-I-correct-an-quot-Invalid-argument-to-sqrt-quot-problem/m-p/954973#M83851</link>
      <description>&lt;P&gt;Thanks to one and all for your most helpful replies.&amp;nbsp;&amp;nbsp; Am happy to report that -- thanks to community members collective guidance -- I'm now able to compute the BRI expression of body roundness, as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;WtHR = waistcir/stature;&lt;/P&gt;&lt;P&gt;*WtHR=round((waistcir/stature)*100,.1);&lt;BR /&gt;*Comment This produced a waist circumference to stature ratio times 100,&lt;BR /&gt;which -- being &amp;gt; 1 -- negated my ability, mathematically, to compute a BRI;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ecc=sqrt(1-(WtHR/3.141592653589793)**2);&lt;BR /&gt;*Comment Calculates eccentricity of the vertical ellipse around the body;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BRI=364.2-365.5*Ecc;&lt;BR /&gt;*Comment BRI is Body Roundness Index. Formula developed by Thomas et al. &amp;nbsp; A healthy&lt;BR /&gt;BRI is generally below 10 on the scale of 1-20, with higher scores indicating a&lt;BR /&gt;rounder body;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Again, thank you one and all for your help.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jan 2025 21:50:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-I-correct-an-quot-Invalid-argument-to-sqrt-quot-problem/m-p/954973#M83851</guid>
      <dc:creator>GaryHeathcote</dc:creator>
      <dc:date>2025-01-02T21:50:57Z</dc:date>
    </item>
    <item>
      <title>Re: How do I correct an "Invalid argument to sqrt" problem?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-I-correct-an-quot-Invalid-argument-to-sqrt-quot-problem/m-p/955008#M83853</link>
      <description>&lt;P&gt;Something that you may find useful: The CONSTANT function. Instead of typing out many digits you can use the CONSTANT('PI') and not have to worry about typo's. Also this function tells someone reading the code what you are using.&lt;/P&gt;
&lt;P&gt;There are other constants such as E and Euler's constant plus somewhat system dependent values BIG and SMALL plus log and square root of the BIG and SMALL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jan 2025 10:54:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-I-correct-an-quot-Invalid-argument-to-sqrt-quot-problem/m-p/955008#M83853</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2025-01-03T10:54:36Z</dc:date>
    </item>
  </channel>
</rss>

