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

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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