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

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

Tips:Using UPDATE to Collapse a Data Set

From sasCommunity
Jump to: navigation, search
data have ;
 input ID VAR_1 VAR_2 VAR_3 ;
001 1 . 3
001 . 2 .
001 . . 4
002 . 2 .
002 1 . .
002 . 2 3
data want ;
  update have (obs=0 keep=id) 
  by id;

The UPDATE statement can be used to collapse a data set within an ID variable. Missing values can be replaced and the latest non-missing value is retained.

The KEEP= data set option on the first instance of HAVE will force the BY variable(s) to be the first variables on the data set WANT. If the KEEP= option had not been used, the original variable order would be maintained.

This creative solution was suggested by user Tom in a SAS Forum thread.

....see also

Submitted By Art Carpenter