Dear All
My Data set looks like this:
ID VAR_A
1 A
1 A
1 A
2 .
2 A
2 A
3 .
3 .
3 .
4 C
4 C
5
5 D
5
I want it to look like this:
ID VAR_A Correct_VAR_A
1 A A
1 A A
1 A A
2 . A
2 A A
2 A A
3 .
3 .
3 .
4 C C
4 C C
5 D
5 D D
5 D
Please help
Randy
Just one unique Var_A values per ID? Just can't think of a scenario
Anyway-
data have;
input ID VAR_A $;
cards;
1 A
1 A
1 A
2 .
2 A
2 A
3 .
3 .
3 .
4 C
4 C
5 .
5 D
5 .
;
data want;
merge have(drop=var_a) have(where=(var_A>' '));
by id;
run;
Yes there is only one unique value per ID
I looked up this solution. But it is much more complicated than the one posted by novinosrin
data have;
input ID status;
cards;
1 .
1 .
1 .
1 5
2 .
2 .
2 6
;
run;
data want;
do until(not missing(status) or last.id );
set have;
by id;
end;
temp=status;
do until(not missing(status) or last.id );
set have;
by id;
_status=temp;output;
end;
drop temp status;
run;
I honestly can't see a need for a double DOW loop i.e. assuming I understood the requirement. Am i missing something
Novinosrin:
I agree with your last statement. I shall test your code later tonight.
Thanks so much.
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!
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.