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

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. 

1 ACCEPTED SOLUTION

Accepted Solutions
MarkDawson
SAS Employee

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 ; 

View solution in original post

5 REPLIES 5
PaigeMiller
Diamond | Level 26

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?

--
Paige Miller
Reeza
Super User
Fuzzy matching?
ballardw
Super User

@Reeza wrote:
Fuzzy matching?

Fuzzy questioning!

sasphd
Lapis Lazuli | Level 10

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
MarkDawson
SAS Employee

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 ; 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1283 views
  • 4 likes
  • 5 in conversation