Hi all,
Here I have tried with the formula but I get a partial output.
By using the sample data set please proceed with the formula code.
data have;
input age bmi diab diab_bln$ alt ast plat albu;
cards;
61.3 25.43252595 1 no 22 18 3.29 3.2
74.4 30.04768905 2 yes 23 17 2.29 4.2
70.4 24.26987561 22 yes 19 21 2.98 4.4
56.4 38.17497196 5 no 33 25 1.97 4.4
75.4 40.96495221 2 yes 49 103 1.84 3.2
69.4 21.60288505 8 no 16 15 2.64 4.1
run;
proc print;
run;
/*Apart from 2 and 22, whatever the value on diab column it should be NO in diab_bln column*/
data want;
set have;
Score =
-1.675+(0.037*age)+(0.094*bmi)+(1.13*(diab_bln = ifn(diab_bln='yes')* 1)) +
(0.99*AST/ALT) - (0.013*plat) - (0.66*albu);
run;
proc print;
run;
This is the exact formula:
NAFLD Score = -1.675 + (0.037*age[years]) + (0.094*BMI) + (1.13*diab [yes = 1, no = 0]) + (0.99*AST/ALT ratio) – (0.013*platelet count [×109/L]) – (0.66*albumin)
You may get any answer by using the formula but
To cross check the result, The given link will use to verify the score value.
https://qxmd.com/calculate/calculator_341/nafld-fibrosis-score
Thanks in advance!
And you may consider breaking up the formula into separate lines so that the single blocks are easier to read:
data want;
set have;
Score =
-1.675 +
(0.037*age) +
(0.094*bmi) +
(1.13*(diab_bln = 'yes')) +
(0.99*AST/ALT) -
(0.013*plat) -
(0.66*albu)
;
run;
Hint: always do a test run of your example data code, to make sure that it works (see the infile statement I had to add)
You are overcomplicating the check for yes/no, try this instead:
data have;
infile cards dlm='09'x;
input age bmi diab diab_bln$ alt ast plat albu;
cards;
61.3 25.43252595 1 no 22 18 3.29 3.2
74.4 30.04768905 2 yes 23 17 2.29 4.2
70.4 24.26987561 22 yes 19 21 2.98 4.4
56.4 38.17497196 5 no 33 25 1.97 4.4
75.4 40.96495221 2 yes 49 103 1.84 3.2
69.4 21.60288505 8 no 16 15 2.64 4.1
run;
data want;
set have;
Score =
-1.675+(0.037*age)+(0.094*bmi)+(1.13*(diab_bln = 'yes')) +
(0.99*AST/ALT) - (0.013*plat) - (0.66*albu);
run;
And you may consider breaking up the formula into separate lines so that the single blocks are easier to read:
data want;
set have;
Score =
-1.675 +
(0.037*age) +
(0.094*bmi) +
(1.13*(diab_bln = 'yes')) +
(0.99*AST/ALT) -
(0.013*plat) -
(0.66*albu)
;
run;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.