Define "weird number". How do we know one when we see one?
Your example input data should include at least one example of each case of "problem" value you expect to process, describe the rule(s) for identifying the problem values, and then show what you actually expect for the output of the same values.
Best is to provide the example values as data step code as we cannot write code against pictures.
Since you example data picture does not show any repeat values of the subject_id it is very hard to tell why you are writing code that appears to expect multiple values for the variable.
I'll get you started on a basic data step to show your example data:
data have;
input subject_id bp_systolic bp_diastolic;
datalines;
1001 131 81
1002 135 74
1003 135 89
;
add values as needed.
Some of "rules" you didn't mention but likely should have for "weird numbers".
1) bp_diastolic greater than or equal to bp_systolic
2) either of those two variables with a value of 0 (zero) or negative
3) From the time I have spent in the hospital I suspect that your organization may have some concern about either of those BP variables over some numeric value. I'm not going to guess but I know my doctor was concerned when mine 181 over 160 one time.
1 should be a simple if/then.
2 and 3 could be implemented with format/informat if involving a single observation. If you insist on attempting to examine multiple observations then you need to describe what you are doing in that case.
You appear to be attempting to report anytime systolic changes in that second code. Why? Hooked up to monitors it fluctuates constantly. If using a stand alone device BP measurement change as fast as the instrument can cycle. And if the measurements are months apart then even looking for "larger" changes, say 10 points or so, may not have any significance.I've had my BP change by 10 or more points in the course of a 30 minute doctor visit.
... View more