replace missing value in certain order

Solved
Frequent Contributor
Posts: 130

replace missing value in certain order

In the sample data, there are two variables, type and datanumber.

type have missing values when datanumber=1 to 41, 43, 45, 159, 259

How to:

=> by the variable 'datanumber', replace type's missing value with 'PARMS, STDERR, T, PVALUE, L95B, UP95B'.

(please refer to datanumber=42 or beyond for those type values' order; one thing worth to mention is that, datanumber=42 may not necessary the first one which don't have missing value in corresponding 'type', in other word, the first 'type' which don't have missing value is random)

Thanks!

Accepted Solutions
Solution
‎08-17-2014 10:27 PM
Posts: 5,543

Re: replace missing value in certain order

Here is one way to do this:

data want;

do i = 1 by 1 until(last.datanumber);

set have; by datanumber;

type = choosec(i, "PARMS","STDERR","T","PVALUE","L95B","U95B");

output;

end;

drop i;

run;

PG

PG

All Replies
Solution
‎08-17-2014 10:27 PM
Posts: 5,543

Re: replace missing value in certain order

Here is one way to do this:

data want;

do i = 1 by 1 until(last.datanumber);

set have; by datanumber;

type = choosec(i, "PARMS","STDERR","T","PVALUE","L95B","U95B");

output;

end;

drop i;

run;

PG

PG
Frequent Contributor
Posts: 130

Re: replace missing value in certain order

Thank you PGStats! that idea is quite straightforward.

🔒 This topic is solved and locked.