I have a table like this, observing the behavior of some accounts in time, here two accounts with acc_ids 1 and 22:
acc_id date mob
1 Dec 13 -1
1 Jan 14 0
1 Feb 14 1
1 Mar 14 2
22 Mar 14 10
22 Apr 14 11
22 May 14 12
I would like to create a column orig_date
that would be equal to date
if mob=0
and to minimum date
by acc_id
group if there is no mob=0
for that acc_id
.
Therefore the expected output is:
acc_id date mob orig_date
1 Dec 13 -1 Jan 14
1 Jan 14 0 Jan 14
1 Feb 14 1 Jan 14
1 Mar 14 2 Jan 14
22 Mar 14 10 Mar 14
22 Apr 14 11 Mar 14
22 May 14 12 Mar 14
The second account does not have mob=0
observation, therefore orig_date
is set to min(date)
by group.
Is there some way how to achieve this in SAS, preferably by one proc sql
step?