I'm a first time user of the forum, have only recently returned to SASing, and am trying to get back in the saddle.
Using SAS 9.2, I am attempting to compute a Body Roundness Index (BRI) from an anthropometric dataset. The BRI computation is broken down into three steps: (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.
In order, the code entered is:
WtHR=round((waistcir/stature)*100, .1);
Ecc=sqrt(1-WtHR/3.14159)**2);
BRI=(364.2 - 365.5)*Ecc;
Running both Proc Print for screening, I've no problem with computed values for WtHR, but receive "." missing values for Ecc and BRI.
The system's objection is "Invalid argument to sqrt".
Is the problem one of syntax, or is it deeper?
Thanks to one and all for your most helpful replies. 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:
WtHR = waistcir/stature;
*WtHR=round((waistcir/stature)*100,.1);
*Comment This produced a waist circumference to stature ratio times 100,
which -- being > 1 -- negated my ability, mathematically, to compute a BRI;
Ecc=sqrt(1-(WtHR/3.141592653589793)**2);
*Comment Calculates eccentricity of the vertical ellipse around the body;
BRI=364.2-365.5*Ecc;
*Comment BRI is Body Roundness Index. Formula developed by Thomas et al. A healthy
BRI is generally below 10 on the scale of 1-20, with higher scores indicating a
rounder body;
Again, thank you one and all for your help.
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.
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 all the messages. Then on the forum open a text box on the forum using the </> icon that appears above the main message window and paste the text and paste the text.
As a minimum that removes any question as to the exact code that was submitted.
An example providing what should be a valid value for the WtHr variable, if maybe not biologically plausible shows:
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
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.
Hello @GaryHeathcote and welcome to the SAS Support Communities!
@GaryHeathcote wrote:
WtHR=round((waistcir/stature)*100, .1);
Ecc=sqrt(1-WtHR/3.14159)**2);
BRI=(364.2 - 365.5)*Ecc;
I agree with the other experts that you should first make sure your formulas are correct before implementing them in code.
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 Body roundness index,
It's possible the correct formula for Ecc just involves squaring the inner part (thus guaranteeing a positive number) before 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. Like this (line breaks and spaces added for emphasis):
Ecc=sqrt(
( 1-WtHR/3.14159 )**2
);
@quickbluefish wrote:
It's possible the correct formula for Ecc just involves squaring the inner part (thus guaranteeing a positive number) before 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.
This would be "possible" (albeit unusual) if we knew nothing about the context of the formula. But the corresponding formula in the Wikipedia article and its explanation clearly show that an opening parenthesis must be inserted after the minus sign:
Ecc=sqrt(1-(WtHR/3.14159)**2);
Only this correction fits the definition of the eccentricity of an ellipse in geometry: see the first table in Wikipedia article Eccentricity (mathematics).
Thanks to one and all for your most helpful replies. 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:
WtHR = waistcir/stature;
*WtHR=round((waistcir/stature)*100,.1);
*Comment This produced a waist circumference to stature ratio times 100,
which -- being > 1 -- negated my ability, mathematically, to compute a BRI;
Ecc=sqrt(1-(WtHR/3.141592653589793)**2);
*Comment Calculates eccentricity of the vertical ellipse around the body;
BRI=364.2-365.5*Ecc;
*Comment BRI is Body Roundness Index. Formula developed by Thomas et al. A healthy
BRI is generally below 10 on the scale of 1-20, with higher scores indicating a
rounder body;
Again, thank you one and all for your help.
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.
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.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.