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

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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