This is a case where use of a temporary array of disasters, indexed by year, and defaulting to 'None" is a nice solution:
data have;
input Country $ Year Disaster :$9.;
datalines;
Afghanistan 1990 Flood
Afghanistan 1993 Epidemic
Afghanistan 2020 Storm
Albania 1992 Landslide
Albania 1994 Storm
run;
data want;
set have;
by country;
array dhist {1990:2020} $9 _temporary_ (31*'None');
dhist{year}=disaster;
if last.country then do year=1990 to 2020;
disaster=dhist{year};
output;
dhist{year}='None';
end;
run;
The _temporary_ array will have its values (i.e. mostly a series of 'None') retained from one observation to the next.
... View more