Hi all, I have an issue with my dataset that I hope you will help me to solve. I am using SAS University Edition v.9.4. In my dataset, which is a panel data sorted by the variables customer ID, year and month, I have some missing values linked to the variable customer_age that I would like to substitute with their lagged values. Below, a small data step of my dataset to play with it around. As you will see, I have four types of missing values: 1. Clients whose age is first observed, then missing and observed again (See cust_id 1). In this case, SAS should substitute the missing value with the previous observation. 2. Client whose age is first missing and then observed (See cust_id 3). In this case, SAS should substitute the missing with the first next observation it can find. In the case of cust_id 3, SAS should substitute the missing values from January 2017 and February 2017 with the customer_age observed on March 2017. 3. Clients whose age is always missing (See cust_id 5). In this case, I would like SAS to delete these observations from the dataset. In other words, if customer_age is a missing value from January 2017 to December 2017, then delete. I hope I've given you the idea of my issue and hopefully you will help! Thank you in advance. data have;
input cust_id year month customer_age;
cards;
1 2017 1 23
1 2017 2 23
1 2017 3 23
1 2017 4 .
1 2017 5 .
1 2017 6 .
1 2017 7 23
1 2017 8 23
1 2017 9 23
1 2017 10 23
1 2017 11 23
1 2017 12 23
2 2017 1 41
2 2017 2 41
2 2017 3 41
2 2017 4 41
2 2017 5 41
2 2017 6 41
2 2017 7 41
2 2017 8 41
2 2017 9 41
2 2017 10 41
2 2017 11 41
2 2017 12 .
3 2017 1 .
3 2017 2 .
3 2017 3 22
3 2017 4 22
3 2017 5 22
3 2017 6 22
3 2017 7 22
3 2017 8 22
3 2017 9 22
3 2017 10 22
3 2017 11 22
3 2017 12 22
4 2017 1 34
4 2017 2 34
4 2017 3 34
4 2017 4 34
4 2017 5 34
4 2017 6 34
4 2017 7 34
4 2017 8 34
4 2017 9 34
4 2017 10 34
4 2017 11 34
4 2017 12 34
5 2017 1 .
5 2017 2 .
5 2017 3 .
5 2017 4 .
5 2017 5 .
5 2017 6 .
5 2017 7 .
5 2017 8 .
5 2017 9 .
5 2017 10 .
5 2017 11 .
5 2017 12 .
6 2017 1 56
6 2017 2 .
6 2017 3 .
6 2017 4 .
6 2017 5 .
6 2017 6 56
6 2017 7 56
6 2017 8 56
6 2017 9 56
6 2017 10 56
6 2017 11 56
6 2017 12 56
7 2017 1 45
7 2017 2 45
7 2017 3 45
7 2017 4 45
7 2017 5 45
7 2017 6 45
7 2017 7 45
7 2017 8 45
7 2017 9 45
7 2017 10 45
7 2017 11 45
7 2017 12 .
;
run;
... View more