BookmarkSubscribeRSS Feed
Mounika2
Calcite | Level 5

data SV (RENAME=(VISIT=TERM));
input PT VISIT$9. STDT: YYMMDD8.;
format STDT is8601da.;
datalines;
101 screening 2017-02-10
102 screening 2017-02-12
103 screening 2017-02-16
104 screening 2017-02-11
run;

data RI;
input PT TERM$13. STDT: is8601da.;
format STDT is8601da.;
datalines;
101 randomization 2017-02-23
102 randomization 2017-02-22
103 randomization 2017-02-20
104 randomization 2017-02-21
run;

data DM (RENAME=(ACTARM=TERM));
input PT ACTARM$ RFSTDTC is8601da.;
format RFSTDTC is8601da.;
datalines;
101 drugA 2017-03-05
102 drugB 2017-03-10
103 drugA 2017-03-06
104 drugB 2017-03-01
RUN;

DATA DS;
INPUT PT TERM$ STDT IS8601DA.;
FORMAT STDT IS8601DA.;
DATALINES;
101 complete 2017-09-23
102 complete 2017-09-20
103 complete 2017-09-24
104 complete 2017-04-22
RUN;

i got the following output by combining the above datasets;

 

data want;
set ri sv dm;
if STDT= " " then STDT=RFSTDTC;
run;
proc sort data=want;
by pt term;
run;

 

output

 

Pt    TERM                 STDTC            RFSTDTC

101 screening           2017-02-10

101 randomization     2017-02-23

101 drugA                  2017-03-05      2017-03-05

101 complete             2017-09-23
102 screening            2017-02-12

102 randomization     2017-02-22

102 drugB                  2017-03-10        2017-03-10

102 complete            2017-09-20
103 screening           2017-02-16

103 randomization    2017-02-20

103 drugA                 2017-03-06        2017-03-06

103 complete            2017-09-24
104 screening           2017-02-11

104 randomization    2017-02-21

104 drugB                 2017-03-01        2017-03-01

104 complete            2017-04-22

 

 

what i want is

 

Pt    TERM                 STDTC            RFSTDTC

101 screening           2017-02-10     2017-03-05

101 randomization     2017-02-23    2017-03-05

101 drugA                  2017-03-05      2017-03-05

101 complete             2017-09-23     2017-03-05
102 screening            2017-02-12   2017-03-10

102 randomization     2017-02-22    2017-03-10

102 drugB                  2017-03-10        2017-03-10

102 complete            2017-09-20        2017-03-10

103 screening           2017-02-16       2017-03-06

103 randomization    2017-02-20       2017-03-06

103 drugA                 2017-03-06        2017-03-06

103 complete            2017-09-24        2017-03-06
104 screening           2017-02-11      2017-03-01

104 randomization    2017-02-21       2017-03-01

104 drugB                 2017-03-01        2017-03-01

104 complete            2017-04-22        2017-03-01

1 REPLY 1
Jagadishkatam
Amethyst | Level 16

Please try the below code on existing dataset

 


data want2;
merge want(drop=RFSTDTC) dm(keep=pt RFSTDTC);
by pt;
run;
Thanks,
Jag

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 1 reply
  • 242 views
  • 0 likes
  • 2 in conversation