Hi I need to merge two tables (Table A , Table B ) the tables look like as illustrated below
Table A (The first column is unique ID for 400 rows, second column is YYYYMM date column goes from 200001 to 201012, third column is Value
CodeId | Date | AUM |
---|---|---|
10326 | 200001 | 200 |
10326 | 200001 | 200 |
10345 | 200003 | 340 |
.... | 200204 | ... |
.... | 200512 | ... |
10328 | 201012 | ... |
Table B (First column has similar unique ID as table A and date in column two is YYYYMM but its random not necessarily continuous dates)
CodeId | Date |
---|---|
10326 | 200001 |
10348 | 200312 |
10356 | 200902 |
Objective : Is to merge the two sheets based on 2 variables (CodeID and Dates) . I need the output to show AUM value in Table B after matching with specific CodeID and specific date.
Output table
CodeID | Date | AUM |
---|---|---|
10326 | 200001 | Value for 10326 and 200001 date from Table A |
10348 | 200312 |
I have tried proc sql using where but didnt work for me , could someone please help me.
hi,
check this....if really want unique 'Codeid'
proc sql;
select distinct a.codeid ,a.aum, b.date from table_a a inner join table_b b
on a.codeid=b.codeid and a.date=b.date ;
run;
Regards
Allu
Or simply
proc sql;
select * from table_A natural join table_B;
quit;
PG
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.