BookmarkSubscribeRSS Feed
deleted_user
Not applicable
i have the data set like this now i wnat the previous obs repeated if the total is '.'



id age tot
1 23 9
2 23 .
3 9 .
4 10 5
3 8 .
6 7 .
5 8 1
4 3 .
2 8 .
1 6 3
3 4 .



ouput

id age tot
1 23 9
2 23 9
3 9 9
4 10 5
3 8 5
6 7 5
5 8 1
4 3 1
2 8 1
1 6 3
3 4 3


in this if the total is '.' then the previous value shd come there
2 REPLIES 2
GertNissen
Barite | Level 11
This is one way of doing it 🙂

data input;
input id age tot;
datalines;
1 23 9
2 23 .
3 9 .
4 10 5
3 8 .
6 7 .
5 8 1
4 3 .
2 8 .
1 6 3
3 4 .
;
run;
data output;
set input;
retain new_tot;
if tot > . then new_tot=tot;
run;
deleted_user
Not applicable
thqs got it

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 2 replies
  • 764 views
  • 0 likes
  • 2 in conversation