これにラグを使用する必要があるかどうかはわかりません。しかし、ここで私がやりたいことです。
これが私が持っているデータです...
acct sort_order type
111111 1 standard
111111 1 standard
111111 2 non-standard
111111 3 other
111111 3 other
222222 2 non-standard
222222 3 other
222222 3 other
これで終わりにしたい…
acct sort_order type want
111111 1 standard standard
111111 1 standard standard
111111 2 non-standard standard
111111 3 other standard
111111 3 other standard
222222 2 non-standard non-standard
222222 3 other non-standard
222222 3 other non-standard
acct と sort_order でデータセットを並べ替えました。アカウントごとに、最初のタイプ (sort_order に基づく) を取得し、それをそのアカウントの各行にコピーします。たとえば、acct 111111 の最初のタイプは「標準」です。acct 111111 のすべての観測で、タイプとして「標準」が必要です。
ラグで次のことをやってみましたが、うまくいきません...
data want;
set have;
by acct;
want = lag(type);
if first.acct then want = type;
run;