DATA Step, Macro, Functions and more

Missing values in data

Reply
Occasional Contributor
Posts: 10

Missing values in data

Hi,

Following is the data I have in a table where  score1 has missing values and  I want to pull value from score2 in score1  where Duration1 is between D1 to D6  where duration2 is D6 and  score1  where Duration1 is between D7 to D10 from score 2 where duration2 is D10. Can someone please advise how it can be done. Thanks in advance.

current dataset

Duration1Score1Duration2Score2
D1
D2
D3
D650D650
D7
D8
D9
D1065D1065

required output as following

Duration1Score1Duration2Score2
D150
D250
D350
D650D650
D765
D865
D965
D1065D1065
Super User
Posts: 5,256

Re: Missing values in data

Resort the data in descending sequence, and then use a data step with retain and conditional assignment.

Data never sleeps
Frequent Contributor
Posts: 106

Re: Missing values in data

data want; set have; obs=_N_;

proc sort data=want;

by descending obs;

data want;

RETAIN score_new;

set want;

IF score1 NE . THEN score_new = score1;

ELSE score1 = score_new;

proc sort data=want out=want(drop=obs score_new);

by obs;

run;

Occasional Contributor
Posts: 10

Re: Missing values in data

Thank you

Ask a Question
Discussion stats
  • 3 replies
  • 194 views
  • 0 likes
  • 3 in conversation