I'm using the following PROC SQL step to pull data:
PROC SQL;
create table panel as
select ID, Month, Var1, Var2, Var3
from data
order by ID, Month;
quit;
I want to use the data to build a balanced panel data set, but there will be IDs missing, which means the value for each variable for each month should equal zero.
I cannot figure out how I can write a query or any data steps that will insert the missing IDs into the data set for each month and then give zeros as values.
For example, my query will make the following table:
UNBALANCED PANEL
My problem is that there is an ID "A" that is not represented in the data that I'm pulling, but ID "A" does exist. Also, to add complexity, ID "C" appears in the PROC SQL intermittently rather than on a monthly basis, but I would like to show it as zeros for each month it does not appear in the database. Therefore, I'm trying to have any missing data for known IDs appear for each month and with zeroes for each Var.
For example:
BALANCED PANEL
This has been stumping me for a few weeks and if anyone has any insights then it would be greatly appreciated!