BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
zimcom
Pyrite | Level 9

I have 5 table to merge all sorted by the common field SUBJECT and part of the view column looks like below

 

 

Type

Length

format

Informat

T_1

SUBJECT

Text

8

$8

$8

T_2

SUBJECT

Text

8

$8

$8

T_3

SUBJECT

Text

8

$8

$8

T_4

SUBJECT

Number

8

BEST.

 

T_5

SUBJECT

Text

8

$8

$8

 

Then I have

proc sort data = T_1; by SUBJECT; run;

proc sort data = T_2; by SUBJECT; run;   

proc sort data = T_3; by SUBJECT; run;

proc sort data = T_4; by SUBJECT; run;

proc sort data = T_5; by SUBJECT; run;   

data all; merge T_1 (in=a) T_2 T_3 T_4 T_5; by SUBJECT; if a; run;

 

the merge was failed due to one of the SUBJECT is number, any suggestion on how to fix this? I tried to convert the numeric SUBJECT to character and renaming, in the end the merge is not working

 

Thank you!

zimcom 

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

Is this what you did?

 

proc sort data = T_1; by SUBJECT; run;

proc sort data = T_2; by SUBJECT; run;   

proc sort data = T_3; by SUBJECT; run;
/*covert to char*/ data T_4(rename=(k=subject)); set T_4; k=put(SUBJECT,8. -l);/*assuming the values are numbers */ drop subject; run; proc sort data = T_4; by SUBJECT; run; proc sort data = T_5; by SUBJECT; run; data all; merge T_1 (in=a) T_2 T_3 T_4 T_5; by SUBJECT; if a; run;

View solution in original post

7 REPLIES 7
novinosrin
Tourmaline | Level 20

Is this what you did?

 

proc sort data = T_1; by SUBJECT; run;

proc sort data = T_2; by SUBJECT; run;   

proc sort data = T_3; by SUBJECT; run;
/*covert to char*/ data T_4(rename=(k=subject)); set T_4; k=put(SUBJECT,8. -l);/*assuming the values are numbers */ drop subject; run; proc sort data = T_4; by SUBJECT; run; proc sort data = T_5; by SUBJECT; run; data all; merge T_1 (in=a) T_2 T_3 T_4 T_5; by SUBJECT; if a; run;
zimcom
Pyrite | Level 9

novinosrin,

the codes works

you saved my life today!

don't know how I should thank you for all the helps you gave to me!

 

zimcom

novinosrin
Tourmaline | Level 20

No biggie. I am glad. I am about to catch the train and go home and enjoy world cup football finals tomorrow croatia vs france. Keep your questions coming. It's fun to ask, find and share. Cheers

zimcom
Pyrite | Level 9

Thank you, you deserve a good relax Sunday and enjoy the game tomorrom

Reeza
Super User

@zimcom wrote:

tried to convert the numeric SUBJECT to character and renaming, in the end the merge is not working

 

Thank you!

zimcom 


This is the correct approach so you likely did something incorrect in that step. If you post that code, we can help point out where the issues is. 

Andygray
Quartz | Level 8

@zimcom You could close the thread my marking some relevant answer as accepted solution rather than leaving completely open for too long

zimcom
Pyrite | Level 9

Hi Andygrey,

Thank you for letting me know. 

As I am still kind of new to this forum (yesterday actually is my very first day here), I will make sure to close my thread as soon as I have an answer. This forum is really helpfull.

 

Have a good day! 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 7 replies
  • 1243 views
  • 2 likes
  • 4 in conversation