As the first step in the decommissioning of sasCommunity.org the site has been converted to read-only mode.


Here are some tips for How to share your SAS knowledge with your professional network.


Tip of the Day:April 29

From sasCommunity
Jump to: navigation, search

sasCommunity Tip of the Day

Did you know that you can use the COALESCE function to find the LAST non-missing value in a list of variables? It is just a matter of how the arguments to the COALESCE function are entered. Here is an example.

data test;
input x1-x5;
if n(of x:) ge 2 then diff = coalesce(of x5-x1) - coalesce(of x:);
datalines;
10 20 30 40 50
. . 20 40 .
10 . . . . 
15 . 25 . 55
. . . . .
;
 
 
the data set ...
x1    x2    x3    x4    x5    diff
10    20    30    40    50     40
 .     .    20    40     .     20
10     .     .     .     .      .
15     .    25     .    55     40
 .     .     .     .     .      .

Note ... the COALESCEC function can also be used in this manner.

Submitted by Mike Zdeb. Contact me at my Discussion Page.



Feel free to comment on this tip.


Prior tip - Next tip - Random Tip

Submit a Tip