BookmarkSubscribeRSS Feed
art_srap
Obsidian | Level 7

Hi SAS experts, could you tell me what is the problem? because the merge didn't work.Thanks for any help.  

https://prnt.sc/rxrvit

10 REPLIES 10
PaigeMiller
Diamond | Level 26

Hello @art_srap 

 

Most of us will not click on a link such as the one you provide. Please post data, code and your SAS log as text by pasting it into the window that appears when you click on the </> icon. This helps keep formatting correct and readable.

--
Paige Miller
art_srap
Obsidian | Level 7

ok, thank you.

art_srap
Obsidian | Level 7

Hi SAS experts, could you tell me what is the problem? because the merge didn't work.Thanks for any help. 

 

data DTC1;
input ID EVENT: $11. AESTDTC: $16.;
format AESTDTC1 yymmdd10.;
AESTDTC1=input(AESTDTC,yymmdd10.);
keep ID EVENT AESTDTC1;
datalines;
102 Vomit 2016-01-12T16:05
102 Headache 2016-01-19
103 Severepain 2016-02-17
102 Migraine 2016-02-18T02:00
103 Nausea 2016-02-19
;
proc sort data=DTC1;
by ID;
run;
data DTC2;
input ID RFSTDTC: $10.;
datalines;
102 2016-01-20
104 2016-01-05
103 2016-02-05
;
proc sort data=DTC1;
by ID;
run;
proc sort data=DTC2;
by ID;
run;
Data DTC3;
merge DTC1 DTC2;
by ID;
run;

Patrick
Opal | Level 21

The merge works as it should and below what it returns. If this is not what you want then please explain what you're after and where below results differs.

Patrick_0-1586693364917.png

 

art_srap
Obsidian | Level 7

Thanks for the reply.

I haven't the last variable in output data https://prnt.sc/rxscbf, but now I now notice in proc print it appears

Ksharp
Super User
Your code is right.
Please select TABLE WORK.DTC3, NOT WORK.DTC1 at top left corner .
Ksharp
Super User
What is your log information ?
art_srap
Obsidian | Level 7

in log everything is ok, but the output is wrong.

data DTC1;
input ID EVENT: $11. AESTDTC: $16.;
format AESTDTC1 yymmdd10.;
AESTDTC1=input(AESTDTC,yymmdd10.);
keep ID EVENT AESTDTC1;
datalines;
102 Vomit 2016-01-12T16:05
102 Headache 2016-01-19
103 Severepain 2016-02-17
102 Migraine 2016-02-18T02:00
103 Nausea 2016-02-19
;
proc sort data=DTC1;
by ID;
run;
data DTC2;
input ID RFSTDTC: $10.;
datalines;
102 2016-01-20
104 2016-01-05
103 2016-02-05
;
proc sort data=DTC1;
by ID;
run;
proc sort data=DTC2;
by ID;
run;
Data DTC3;
merge DTC1 DTC2;
by ID;
run;
Patrick
Opal | Level 21

@art_srap 

Please post the same question only once. Answer to your duplicate here.

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
  • 10 replies
  • 1249 views
  • 2 likes
  • 5 in conversation