BookmarkSubscribeRSS Feed
jerry898969
Pyrite | Level 9
I have a simple question that I can't seem to figure out.

I have data like this

2000 1 2
. 1 3
. 1 4
2001 2 1
. 2 2
2002 3 1
. 3 2
. 3 3

How can I make the year show up for every row like this

2000 1 2
2000 1 3
2000 1 4
2001 2 1
2001 2 2
2002 3 1
2002 3 2
2002 3 3

Thank you
4 REPLIES 4
art297
Opal | Level 21
Jerry,

The are a number of ways. The one I usually use is:
[pre]
data want (drop=hold);
set have;
retain hold;
if not(missing(year)) then hold=year;
year=ifn(missing(year),hold,year);
run;
[/pre]
HTH,
Art
jerry898969
Pyrite | Level 9
art,

That was it. Thank you so much
SPR
Quartz | Level 8 SPR
Quartz | Level 8
Hello Jerry898969,

This is a solution:
[pre]
data i;
input y b c;
datalines;
2000 1 2
. 1 3
. 1 4
2001 2 1
. 2 2
2002 3 1
. 3 2
. 3 3
run;
data r;
retain y0;
set i;
if y NE . then y0=y;
else y=y0;
drop y0;
run;
[/pre]
Sincerely,
SPR
jerry898969
Pyrite | Level 9
SPR,

Thank you for your reply.

Jerry
What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 2526 views
  • 0 likes
  • 3 in conversation