DO-IF doesn’t seem to like missing values. Is there a way of specifying missing values that DO-IF will accept?
My data was derived by linking 3 system files (match files) the result of which creates a variable where some records have system missing values, but that’s perfectly logical the way the data is structured. Datasets have been used, though I wouldn’t expect that to make any difference to my issue; I just mention it for completeness. I’ve included only 3 records of my data in the examples for clarity. 1: My initial use of DO-IF came out wrong. There should be no missing values for CAP. compute IndexFactor = 1.017. do if (passrate ge 75). + compute cap = n558 * 1.1 * IndexFactor. else if (passrate ge 50). + compute cap = n558 * 0.75 * IndexFactor. else if (passrate lt 50). + compute cap = n558 * 0.5 * IndexFactor. else if missing(passrate). + compute cap = n558 * 0.75 * IndexFactor. else. + compute cap = -9. end if. list vars = e307 passrate n558 IndexFactor cap. e307 passrate n558 IndexFactor cap 10052NAT 100.00 2360.00 1.02 2640.13 AHC50410 57.38 1640.00 1.02 1250.91 BSB50215 . 2240.00 1.02 . 2: Setting PASSRATE to zero works as shown in my edited DO-IF statement. if missing(passrate) passrate = 0. compute IndexFactor = 1.017. do if (passrate ge 75). + compute cap = n558 * 1.1 * IndexFactor. else if (passrate ge 50). + compute cap = n558 * 0.75 * IndexFactor. else if (passrate eq 0). + compute cap = n558 * 0.75 * IndexFactor. else. + compute cap = -9. end if. list vars = e307 passrate n558 IndexFactor cap. e307 passrate n558 IndexFactor cap 10052NAT 100.00 2360.00 1.02 2640.13 AHC50410 57.38 1640.00 1.02 1250.91 BSB50215 .00 2240.00 1.02 1708.56 |
You need to put the missing test first as otherwise the other expressions can't be evaluated, so the else clauses won't be evaluated. On Sun, Jan 8, 2017 at 4:04 PM Ron0z <[hidden email]> wrote: DO-IF doesn’t seem to like missing values. Is there a way of specifying |
Perfect. Thank you. So, simple.
|
In the long run it is a great aid in quality assurance and debugging to reserve "system missing" for situations where the system cannot follow your instructions.
User missing values can carry all the reasons why a values would be missing. If you complete the prep of your 3 input system files, they would contain no system missing values. It would only take a few lines of syntax to clean up the system missing values that are created in the match. something like recode myvars (sysmis = -9999999) (else=copy). If you have preserved the previous syntax so you can go back and change your syntax so it does what you mean rather than what you say, then this is an instance where it would not be shooting yourself in the foot to skip INTO on the recode.
Art Kendall
Social Research Consultants |
Free forum by Nabble | Edit this page |