Hello,
I have a question for getting the next non missing value for the same variable, in other words I'm trying to move up the non missing values so my missing value will be at the bottom of the variable. Below table is the example that I'm trying to create, how can I do that with SAS procedure ? Thank you.
X | Y | Y_New |
1 | 5 | 5 |
2 | . | 7 |
3 | 7 | 6 |
4 | 6 | . |
Hi..
Im not sure the result, in which scenario do you really want.. here is the simple code using many to many merge..
data have;
input x y ;
cards;
1 5
2 .
3 7
4 6
5 .
6 .
7 3
;
run;
proc print data = have;
run;
data want;
merge have(keep = x) have(keep = y where = (y is not missing));
run;
proc print;
run;
Thanks,
Yash
Maybe your example is oversimplified... but this would do it :
data want;
set have(keep=x);
if not endy
then set have(keep=y where=(y is not missing)) end=endy;
else call missing(y);
run;
PG
with simple steps;
data in ;
input x y;
ord=_n_;
cards;
1 .
2 .
3 7
4 6
5 7
6 .
7 0
;
run;
data y;
set in (keep=y where=(y^=.));
ord=_n_;
run;
data out;
merge in (drop=y) y;
by ord;
drop ord;
run;
Hi..
Im not sure the result, in which scenario do you really want.. here is the simple code using many to many merge..
data have;
input x y ;
cards;
1 5
2 .
3 7
4 6
5 .
6 .
7 3
;
run;
proc print data = have;
run;
data want;
merge have(keep = x) have(keep = y where = (y is not missing));
run;
proc print;
run;
Thanks,
Yash
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.