Reputation: 1537
I have (b.sslag1 - b.sslag100)
. Is there any built-in function in SAS can accomplish the same goal while improve its efficiency?
(case when a.ss = . and b.sslag1 ^=. then b.sslag1
when a.ss = . and b.sslag1 =. and b.sslag2 ^=. then b.sslag2
when a.ss = . and b.sslag1 =. and b.sslag2 =. and b.sslag3 ^=. then b.sslag3
when a.ss = . and b.sslag1 =. and b.sslag2 =. and b.sslag3 =. and b.sslag4 ^=. then b.sslag4
....
else a.ss end) as ss
Upvotes: 1
Views: 86
Reputation: 21294
Use the coalesce function.
coalesce(a.ss, b.sslag1, b.sslag2, b.sslag3, b.sslag4) as ss
In a data step you can use the short hand notation. Short hand notation does not work in PROC SQL.
coalesce(a.ss, of b.sslag1-b.sslag100);
Upvotes: 4