- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
Here I have a sample dataset.
In the calculation method, I get confused in the line which I mention as comment
data have;
input age bmi ht dd;
cards;
25 26.2 176 2
56 25.3 156 1
84 45.2 182 3
57 22.8 145 2
78 32.2 155 5
69 21.6 103 4;run;
data want;
set have;
value =
1.235 +
(0.2*age) +
(1.13 * (dd=2)*1) +
(1.21*ht);
run;
/**(1.13 * dd[yes=1,no=0])) +**/
/**(dd=2,1)YES, (dd=Other dd value)NO**/
/**Here the condition reached for dd=2 so (1.13*1) else dd=(any) (1.13*0)**/
Here the code states dd=2 so (Yes) it taken as 1
How do I add the another one condition for dd=1 in the same parameter. (dd=2,1 (YES) else (NO))
Thanks in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I can't say whether the logic is correct or not. But you have to realize that the section you are adding to the formula would add 0 every time, so there is really no need to add it in this case. At any rate, here's what the additional piece of the formula would look like:
(1.13 * (dd=1) * 0) +
If it's possible that DD could be neither 1 nor 2, you might want:
(1.13 * (dd ne 1) * 0) +
But either way, the net result is adding 0 to the original formula.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
(dd=2)
will give you a value of 1 if true, and 0 if false. Multiplying it with 1 solves no purpose.