Page 2 of 2

Re: Compute Variable with if...than....

Posted: Fri Dec 09, 2022 11:07 am
by MAgojam
Hey @Lauri,
fix the Computed Variable C with this:

Code: Select all

IFMISS(A or B, 0, IF(A == 1 or B == 1, 1, 0))
Cheers,
Maurizio

Re: Compute Variable with if...than....

Posted: Mon Dec 12, 2022 11:42 pm
by jonathon
hi,

so a missing value in statistics means "don't know", so that's why IF(A == 1 or B == 1) results in a "don't know" when both A and B are missing, or where one of them is zero, and the other is missing -- without those values we "don't know".

how about the following?

IFMISS(A, 0, A) or IFMISS(B, 0, B)

jonathon

Re: Compute Variable with if...than....

Posted: Tue Dec 13, 2022 7:13 pm
by Lauri
Hey guys thank you so much - I got the solution with your support !!!

Just one mystery remains:
IFMISS(h_1 or h_4 or h_5 or h_7, 0, IF((h_1 == 1 and h_4 > 1 and h_5 == 0) or (h_7 == 1), 1, 0))

I get the correct result in all cases except for this case:
(h_1 == 1 and h_4 > 1 and h_5 == 0) - > not fulfilled
and for the second term: (h_7 == 1) - > there is no value (so no value for variable h_7)

What is my misconception?
Thank you guys !

Re: Compute Variable with if...than....

Posted: Tue Dec 13, 2022 10:43 pm
by MAgojam
Hey @Lauri,
is this what you were looking for?
screenshot.PNG
screenshot.PNG (40.35 KiB) Viewed 1675 times

Code: Select all

IF(IFMISS(h_1,0,h_1)==1 and IFMISS(h_4,0,h_4)>1 and IFMISS(h_5,0,h_5)==0 or IFMISS(h_7,0,h_7)==1,1,0)
Cheers,
Maurizio

Re: Compute Variable with if...than....

Posted: Wed Dec 14, 2022 5:08 pm
by Lauri
Amazing - thank you very much Maurizio!!!

Table $ setRow (): value ´est´ is not atomic

Posted: Mon Jan 09, 2023 1:49 pm
by Lauri
When adding another covariate in the calculation of a binominal logistic regression, this error message appeared. I have tried various things, but the error message persists. Does anyone have any ideas? Thanks a lot

Re: Compute Variable with if...than....

Posted: Wed Jan 11, 2023 11:52 pm
by jonathon
hmm ... i think we need to start from a truth table. is this correct?

A, B, C
0, 0, 0
0, 1, 1
0, NA, 0,
1, 0, 1
1, 1, 1
1, NA, 1
NA, 0, 0
NA, 1, 1
NA, NA, 0

Re: Compute Variable with if...than....

Posted: Fri Jan 13, 2023 2:39 pm
by Lauri
Yes, that is correct

Re: Compute Variable with if...than....

Posted: Fri Jan 13, 2023 11:47 pm
by jonathon
i feel like this ought to do it:

IFMISS(A, 0, A) or IFMISS(B, 0, B)

a slightly longer way might be to recode A and B into separate columns ... this is nice and expressive as it makes clear that you're 'recoding' the missing values in your columns. and then perform the 'or' on the resultant columns.

jonathon