Selecting the rightmost variable of several columns

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Selecting the rightmost variable of several columns

rmjdgeh
Dear list,

Does anyone know how I can select value from the "rightmost" of a set of columns?

For example, each column might represent the same variable measured in different years. I want to select the most recent information, because the value might be missing for the current year.

Many thanks,
Gareth
Reply | Threaded
Open this post in threaded view
|

Re: Selecting the rightmost variable of several columns

Bruce Weaver
Administrator
rmjdgeh wrote
Dear list,

Does anyone know how I can select value from the "rightmost" of a set of columns?

For example, each column might represent the same variable measured in different years. I want to select the most recent information, because the value might be missing for the current year.

Many thanks,
Gareth
If I follow, you want to do something like this.

* Read in some sample data.
data list / v1 to v3 1-3 .
begin data.

1
 2
  3
12
 23
123
end data.

* Pick out right-most valid value.

numeric rigthmost (f2.0).
do repeat v = v1 to v3.
- if not missing(v) rightmost = v.
end repeat.
list.

HTH.
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).