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

Hi All,

Please help achieve the below result
I have two tables, Dept1 and details, now i need to create a new table where i need to add the date joining based on the Dept1 column values and the Leave date would be set to a default date of 31Dec9999 for all the columns Emp_Id is missing.

 

Table 1

Details      
Emp_IdNameDeptSalaryDate of JoiningLOPDept1
A001ATech1230013-Jan-1614-Jan-16Tech
A002BAdmin450016-Apr-1517-Apr-15Admin
A003CHosp897016-Apr-1517-Apr-15Hosp
A004DTech87652-Apr-152-Apr-15Tech
A005ETech435679-Apr-159-Apr-15Tech
A006FHosp908728-Apr-1512-May-15Hosp
A087GAdmin987620-Jan-1321-Jun-16Admin
E00057HTech1234517-Mar-1519-Mar-15Tech
E0041IAdmin764517-Mar-1518-Mar-15Admin
E00062JTech8907514-Aug-1414-Aug-14Tech
E00015KTech3456522-May-139-Oct-13Tech
E00076LHosp56720-Jan-1322-Jun-16Hosp
 M MTech8970  Tech
 NNAdmin8765  Admin
 OOHosp43567  Hosp
 PPTech9087  Tech
 QQTech9876  Tech
 RRHosp7645  Hosp
 SSAdmin89075  Admin
 TTTech34565  Tech
 UUAdmin567  Admin
 VVTech7645  Tech
 WWTech89075  Tech
 XXHosp34565  Hosp
 YYHosp89075  Hosp
 ZZHosp34565  Hosp

 

Table 2:

 

Dept 1  
DeptDate of JoiningDate of Leave
Tech13-Jan-1614-Jan-16
Admin16-Apr-1517-Apr-15
Hosp16-Apr-1517-Apr-15
Tech2-Apr-152-Apr-15
Tech9-Apr-159-Apr-15
Hosp28-Apr-1512-May-15
Admin20-Jan-1321-Jun-16
Tech17-Mar-1519-Mar-15
Admin17-Mar-1518-Mar-15
Tech14-Aug-1414-Aug-14
Tech22-May-139-Oct-13
Hosp20-Jan-1322-Jun-16

 

Results:

 

   Result   
Emp_IdNameDeptSalaryDate of JoiningLOPDept1
A001ATech1230013-Jan-1614-Jan-16Tech
A002BAdmin450016-Apr-1517-Apr-15Admin
A003CHosp897016-Apr-1517-Apr-15Hosp
A004DTech87652-Apr-152-Apr-15Tech
A005ETech435679-Apr-159-Apr-15Tech
A006FHosp908728-Apr-1512-May-15Hosp
A087GAdmin987620-Jan-1321-Jun-16Admin
E00057HTech1234517-Mar-1519-Mar-15Tech
E0041IAdmin764517-Mar-1518-Mar-15Admin
E00062JTech8907514-Aug-1414-Aug-14Tech
E00015KTech3456522-May-139-Oct-13Tech
E00076LHosp56720-Jan-1322-Jun-16Hosp
 M MTech897013-Jan-1612-Dec-99Tech
 NNAdmin876516-Apr-1512-Dec-99Admin
 OOHosp4356716-Apr-1512-Dec-99Hosp
 PPTech90872-Apr-1512-Dec-99Tech
 QQTech98769-Apr-1512-Dec-99Tech
 RRHosp764528-Apr-1512-Dec-99Hosp
 SSAdmin8907520-Jan-1312-Dec-99Admin
 TTTech3456517-Mar-1512-Dec-99Tech
 UUAdmin56720-Jan-1312-Dec-99Admin
 VVTech764514-Aug-1412-Dec-99Tech
 YYHosp8907520-Jan-1312-Dec-99Hosp
 ZZHosp3456520-Jan-1312-Dec-99Hosp
1 ACCEPTED SOLUTION
2 REPLIES 2
RahulG
Barite | Level 11

It seems you do not have primary key column in two tables. Whatever way you do the output would need to verified throughly.

 

If you are very sure that records that need to be joined are in same order in both the tables then in that case create new numeric column NEW_COLUMN  in both the table and store record number that may be _N_  or something else whatever you like. This new column would act as suggorate key and now you can join two table with NEW_COLUMN and dept1.

 

 

 

 

 

 

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
  • 2 replies
  • 888 views
  • 1 like
  • 3 in conversation