Please help -
I am trying to have an end result of one number from 4 columns. If column 1 is not blank, then show column 1, if it is blank, show column 2, if column 2 blank show column 3, if column 3 blank use column 4 and if column 4 is blank, leave blank. I used the following expression but I am clearly doing something wrong. Any help would be appreciated.
ifn(t1.'Material Group'n not missing,t1.'Material Group'n, ifn(t1.'Material Group #'n not missing, t1.'Material Group #'n), ifn(t1.'Matl Grp'n not missing, t1.'Matl Grp'n, ifn(t1.'Material Group #1'n not missing, t1.'Material Group #1'n, "")))
If you provide some example data and the log it would be helpful in troubleshooting what your issue is.
Below I've provided an example of what I assume you are trying to do. You can try to make necessary corrections on your side from there.
data have;
input a b c d;
datalines;
1 . . .
. 3 . .
. . 4 .
. . . 2
;
run;
data want;
set have;
test = ifn(not missing(a), a, ifn(not missing(b), b, ifn(not missing(c), c, ifn(not missing(d), d,0))));
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.
Ready to level-up your skills? Choose your own adventure.