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-2024.png

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.

 

Register now!

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
  • 1843 views
  • 0 likes
  • 3 in conversation