Hi SAS Forum,
I have been trying to merge the attahced two files (simplified ver) for hours using the below code but could not.
Specific question:
File_A has a single record whic is not taken into the merged file called "COMBINED_file". There is no any errors in the log too.
Could anyone please help me.
proc sort data=A.BOOK1 out=file_A;
by bank_number Account_number ;
run;
proc sort data=A.BOOK2 Out=file_B;
by bank_number account_number ;
run;
data COMBINED_file;
merge file_A (IN=a)
file_B (IN=b)
;
by bank_number account_number ;
if a and b;
run;
Thanks
Mirisage
Worked fine for me. I got 5 records in the result file. I am using SAS 9.3 TS0M1 and did the merge with your code and with SQL.
Maybe you need to reframe your question and show us what you want the results to look like.
Doc Muhlbaier
Duke
I just saw your postings in the SAS Procedures forum. For the sake of your fellow community members, please post your questions to just one forum.
Thanks,
Doc
Hi Doc,
Thank you.
I am sorry I wanted to post this in SAS procedures forum only. I posted it. Then it did not appear in SAS procedures forum. Then I again posted. Then appeared.
I can now understand what has happened. I have first posted in this forum inadvertently.
I apologize.
Best regards
Mirisage
hi can u please tel me how to merge two files without any common variables.
ex:
first table.
itemcode item name stock
111 colgate toothpaste 10
222 pepsodent 20
second table.
customer id name product count
501 selva vatika 3
502 kumar meera 5
Next time, you should post your new question as a new discussion...
If you want to merge two datasets on the order of observations (first obs from first dataset with first obs from second dataset, etc.) then do :
data third;
set first;
set second;
run;
dataset third will have as many observations as the shortest of first and second datasets.
PG
You could check out the following link, which references a section in the SAS documentation that covers combining SAS datasets. It's powerful, but not like any other language out there (quite different from SQL).
Tom
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.