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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

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