BookmarkSubscribeRSS Feed
gopilth
Calcite | Level 5

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
3 REPLIES 3
LinusH
Tourmaline | Level 20

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

Data never sleeps
pradeepalankar
Obsidian | Level 7

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;

gopilth
Calcite | Level 5

Thank you

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1054 views
  • 0 likes
  • 3 in conversation