Dataset looks like this -
Name ID flag1.
AJ 1 1
AJ 1 .
AJ 1 .
AJ 2 .
How do I make dataset looks like this -
Name ID flag1. varWant
AJ 1 1 1
AJ 1 . 1
AJ 1 . 1
AJ 2 . .
Thanks!
As long as your data set is sorted by Name and ID:
data want;
set have;
by name id;
if first.id or flag1 > . then varWant = flag;
retain varWant;
run;
To clarify - I want the first obs for flag within a group (name AND ID) to carry down
As long as your data set is sorted by Name and ID:
data want;
set have;
by name id;
if first.id or flag1 > . then varWant = flag;
retain varWant;
run;
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!
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.