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-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!

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.

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
  • 816 views
  • 0 likes
  • 3 in conversation