UNIQUEVALUES—Extracts an ordered set of unique values

Use this forum to post complete RATS "procedures". Please be sure to include instructions on using the procedure and detailed references where applicable.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

UNIQUEVALUES—Extracts an ordered set of unique values

Unread post by TomDoan »

This procedure returns a vector of sorted unique values for an input series over an indicated range.
uniquevalues.src
Procedure file
(1.07 KiB) Downloaded 1046 times
@UniqueValues(values=VECTOR,other options) series start end

Options

values=VECTOR of values found in the series [required]
smpl=dummy with 0's in entries to skip [not used]

The following shows it in use. The data set (from Greene's Econometric Analysis) is an unbalanced panel, with individuals indexed by the "ID" series. UniqueValues generates a sorted list of the individuals into the VECTOR named VID.

Code: Select all

open data rwm.txt
data(format=free,org=columns) 1 27326 id female year age hsat handdum $
 handper hhninc hhkids educ married haupts reals fachhs abitur univ $
 working bluec whitec self beamt docvis hospvis public addon
@uniquevalues(values=vid) id
Post Reply