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

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 1057 views
  • 0 likes
  • 2 in conversation