SAS (and SQL) operates row by row from the original data set (or here, the product of two data sets joined).
If you had YYYY value of 2019 on one row, and value YYYY of 2020 on another row, for the same ID, that's going to come out in the resulting data set, row by row, just as before. Thus, on the row where YYYY = 2019, the variable Star2020 can't have a value because the criterion is not satisfied.
In order to produce the result you showed, you would need at least one more step in SQL, or approach it differently from the beginning.
One way to get this result, following the SQL you showed, is to "group by" all the variables that are identical across the rows to the level you desire, then use the max() function for any numeric variables where you want the value to show in the end and not the blank / missing.
proc sql;
create table Stars_Compare2 as
select ID,
<Other Variables>,
max(Star2019) as Star2019,
max(Star2020) as Star2020
from Stars_Compare
group by ID, <Other Variables>;
quit;