BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Sas_R
Calcite | Level 5

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.

XYY_New
155
2.7
376
46.
1 ACCEPTED SOLUTION

Accepted Solutions
yaswanthj
Calcite | Level 5

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

View solution in original post

3 REPLIES 3
PGStats
Opal | Level 21

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

PG
Amarnath7
Fluorite | Level 6

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;

yaswanthj
Calcite | Level 5

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 839 views
  • 3 likes
  • 4 in conversation