In this particular case, one must do a little gymnastics to fix the beginning and end of the series :
data temp(drop=i first:) first(keep=first:);
set have end=done;
array v{*} v:;
array first{1024} (1024*.);
do i = 1 to dim(v);
if v{i}=0 then call missing (v{i});
else if missing(first{i}) then first{i} = v{i};
end;
output temp;
if done then output first;
run;
proc expand data=temp out=expanded;
id id;
convert v: / method=join;
run;
data want;
if _n_=1 then set first;
set expanded;
array v{*} v:;
array first{*} first:;
do i = 1 to dim(v);
if missing(v{i}) then
if missing(first{i}) then v{i} = 0;
else v{i} = first{i};
else call missing(first{i});
end;
drop i first:;
run;
PG
@art297,
I posted a PROC EXPAND example and another using PROC TRANSREG for good measure.
For further reading I would recommend the following topic from SAS-L:
In this particular case, one must do a little gymnastics to fix the beginning and end of the series :
data temp(drop=i first:) first(keep=first:);
set have end=done;
array v{*} v:;
array first{1024} (1024*.);
do i = 1 to dim(v);
if v{i}=0 then call missing (v{i});
else if missing(first{i}) then first{i} = v{i};
end;
output temp;
if done then output first;
run;
proc expand data=temp out=expanded;
id id;
convert v: / method=join;
run;
data want;
if _n_=1 then set first;
set expanded;
array v{*} v:;
array first{*} first:;
do i = 1 to dim(v);
if missing(v{i}) then
if missing(first{i}) then v{i} = 0;
else v{i} = first{i};
else call missing(first{i});
end;
drop i first:;
run;
PG
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.