I have a requirement to compare two file NAMES
the first file contains all companies in the database and the other file contains the list of compagnies that I want to find.
I want the output give the list of compagnies find in the all campagnies file.
Try using the EQT operator which does a truncated comparison based on the shortest value
data all_companies ;
infile datalines truncover ;
input secid:$12. Name_MS $50. ;
datalines ;
0P0000K4GS Abengoa SA ADR
0P0000ETZM Abcourt Mines Inc Class B
0P000177DG Abdul Mohsen Al-Hokair Group for Tourism and Development Co
; run ;
data list_of_compagnies ;
infile datalines truncover ;
input M_id M_name $50. ;
datalines ;
21 Abengoa
24 ABN AMRO Bank
25 ABO Wind
26 Aboitiz Power Corp
; run ;
proc sql ;
create table results as
select M_id, M_name, secid, Name_MS
from list_of_compagnies, all_companies
where list_of_compagnies.M_name eqt all_companies.Name_MS ;
quit ;
I have a requirement to compare two file NAMES
It sounds like you are asking elsewhere to compare company names, not file names. Can you explain further?
Also, can you provide brief example data sets?
@Reeza wrote:
Fuzzy matching?
Fuzzy questioning!
this an example
all companies | |
secid | Name_MS |
0P0000K4GS | Abengoa SA ADR |
0P0000ETZM | Abcourt Mines Inc Class B |
0P000177DG | Abdul Mohsen Al-Hokair Group for Tourism and Development Co |
list of compagnies | |
M_id | M_name |
21 | Abengoa |
24 | ABN AMRO Bank |
25 | ABO Wind |
26 | Aboitiz Power Corp |
the output that I want to have
M_id | M_name | secid | Name_MS |
21 | Abengoa | 0P0000K4GS | Abengoa SA ADR |
Try using the EQT operator which does a truncated comparison based on the shortest value
data all_companies ;
infile datalines truncover ;
input secid:$12. Name_MS $50. ;
datalines ;
0P0000K4GS Abengoa SA ADR
0P0000ETZM Abcourt Mines Inc Class B
0P000177DG Abdul Mohsen Al-Hokair Group for Tourism and Development Co
; run ;
data list_of_compagnies ;
infile datalines truncover ;
input M_id M_name $50. ;
datalines ;
21 Abengoa
24 ABN AMRO Bank
25 ABO Wind
26 Aboitiz Power Corp
; run ;
proc sql ;
create table results as
select M_id, M_name, secid, Name_MS
from list_of_compagnies, all_companies
where list_of_compagnies.M_name eqt all_companies.Name_MS ;
quit ;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.