On Tue, 4 Feb 2003, Karen Snape wrote:
> Does anyone know the SPSS function equivalent to the "retain" statement in
> SAS?
>
> I want to create a new variable from an existing variable and copy the
> results down the rows (over missing values) until the next valid row.
Karen,
Assuming the variables are numeric and the missing values are blank cells,
i.e. system-missing, you need two SPSS functions: SYSMIS to test if
system-missing, and LAG to obtain the value from the previous case. I've
used syntax here, or you could use the GUI interface and
Transform/Compute, with the If button to set the condition.
* Copy v1 into v2.
COMPUTE v2=v1.
* Change any system-missing values to the previous value.
IF SYSMIS(v2) v2=LAG(v2).
* Run pending transforms.
EXECUTE.
For string data with blank cells you would have to define v2 as a
string variable and might then use
IF (v2='') v2=LAG(v2).
-----------------------------------------------------------------------------
Paul Callow, M.A., Ph.D. Phone 01223-335468 (direct)
University of Cambridge Computing Service 01223-334600 (switchboard)
New Museums Site, Pembroke St, Fax 01223-334679
Cambridge CB2 3QH
|