Please, anyone from SAS community provide me a solution, if you are available.
Dear PeterClemmensen,
In relation to my previous task, I again bumped into an obstacle.
Now, I proc sorted my dataset by cusip(=firm id), Analyst_id, Annc_date, and Span_closing.
Span_closing is the final 1-year span before a house closes.
cusip
House_id
Analyst_id
Annc_date
Span_closing
00030710
2143
134474
2/23/2016
0
00030710
2143
134474
3/18/2016
0
00030710
2143
134474
8/5/2016
1
00030710
2143
134474
11/4/2016
1
00030710
2143
134474
2/27/2017
1
00030710
2143
134474
3/1/2017
1
00030710
3945
165909
10/23/2015
1
00030710
3945
165909
2/5/2016
1
00030710
3945
165909
2/24/2016
1
00032Q10
926
194378
8/30/2021
1
00032Q10
926
194378
11/11/2021
1
00036020
371
1112
3/22/1994
0
00036020
371
1112
6/7/1994
0
00036020
371
1112
11/21/1994
0
00036110
32
136
6/29/1989
0
00036110
32
136
1/4/1990
0
00036110
32
136
3/29/1990
1
00036110
32
136
5/10/1990
1
00036110
32
136
8/2/1990
1
00036110
32
136
8/15/1990
1
00036110
32
136
8/30/1990
1
00036110
32
136
10/24/1990
1
00036110
32
136
10/31/1990
1
00036110
32
136
1/10/1991
1
00036110
479
136
5/2/1991
0
00036110
479
136
8/27/1991
0
00036110
479
136
9/12/1991
0
00036110
479
136
10/1/1991
0
00036110
479
136
10/31/1991
0
00036110
479
136
12/30/1991
0
00036110
479
136
4/2/1992
0
00036110
479
136
7/1/1992
0
00036110
479
136
12/21/1992
0
00036110
479
136
1/26/1993
0
00036110
165
278
9/8/1988
0
In this dataset, you can see that Analyst_id= 134474, who was working for the house 2143, stopped working (i.e., disappeared) as soon as the house 2143 closes (Span_closing=1, especially on 3/1/2017).
It is also the case with Analyst_id= 165909 working for the house 3945, and with Analyst_id= 194378 working for the house 926. You can simply leave such cases.
However, Analyst_id= 136, who used to work for the house 32, enters the final year span of the house 32 (Span_closing=1), and after the house closes, he continues to work for another house 479. For such an analyst like him, I'd like to create a new variable "Analyst_persist" that highlights his 1-year span (5/2/1991~4/2/1992) in which he works for a new house.
That is, I'd like to create a dataset like below:
cusip
House_id
Analyst_id
Annc_date
Span_closing
Analyst_persist
00030710
2143
134474
2/23/2016
0
0
00030710
2143
134474
3/18/2016
0
0
00030710
2143
134474
8/5/2016
1
0
00030710
2143
134474
11/4/2016
1
0
00030710
2143
134474
2/27/2017
1
0
00030710
2143
134474
3/1/2017
1
0
00030710
3945
165909
10/23/2015
1
0
00030710
3945
165909
2/5/2016
1
0
00030710
3945
165909
2/24/2016
1
0
00032Q10
926
194378
8/30/2021
1
0
00032Q10
926
194378
11/11/2021
1
0
00036020
371
1112
3/22/1994
0
0
00036020
371
1112
6/7/1994
0
0
00036020
371
1112
11/21/1994
0
0
00036110
32
136
6/29/1989
0
0
00036110
32
136
1/4/1990
0
0
00036110
32
136
3/29/1990
1
0
00036110
32
136
5/10/1990
1
0
00036110
32
136
8/2/1990
1
0
00036110
32
136
8/15/1990
1
0
00036110
32
136
8/30/1990
1
0
00036110
32
136
10/24/1990
1
0
00036110
32
136
10/31/1990
1
0
00036110
32
136
1/10/1991
1
0
00036110
479
136
5/2/1991
0
1
00036110
479
136
8/27/1991
0
1
00036110
479
136
9/12/1991
0
1
00036110
479
136
10/1/1991
0
1
00036110
479
136
10/31/1991
0
1
00036110
479
136
12/30/1991
0
1
00036110
479
136
4/2/1992
0
1
00036110
479
136
7/1/1992
0
0
00036110
479
136
12/21/1992
0
0
00036110
479
136
1/26/1993
0
0
00036110
165
278
9/8/1988
0
0
I tried to make a little modification of your previous codes and achieve this, but, unfortunately, my understanding of the sas function intnx is very limited and I couldn't do it.
I'd really appreciate it, if you give me a hand one more time!
Sincerely,
KS -,
... View more