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

good day,

 

 

below is my program


%macro sqlmerchant(A=,B=,C=,ab=);

 

PROC SQL;
CREATE TABLE &A AS
SELECT * ,"&ab" AS NAME ,"Y" as Cleaned_flag FROM Merch_clean_latest_raw_backup
WHERE Merchant_Name LIKE &b
AND "merchant_name_alias.mcc"N IN (SELECT MCC FROM Merchant_list_v2 WHERE 'Merchant Category'n in &C )
;

%MEND;

 

%sqlmerchant(A=MCDONALD,B="%MCDONALD%",C=("Miscellaneous Stores"),ab=Mcdonald);

%sqlmerchant(A=WATSONSWINE,B="%WATSONSWINE%",C=("Miscellaneous Stores"),ab=Watsons Wine);

%sqlmerchant(A=WATSONS,B="%WATSONS%",C=("Miscellaneous Stores"),ab=Watsons);

 

 

here is my macro code.I have to search a list of merchant in a big data base.

 

and the list of merchant name and merchant code are stored in two excel.

 

can i set up a program which can let the macro read from the excel automatically . so that i can avoid to input all my name list into macro.

 

thanks in advance,

Harry

1 ACCEPTED SOLUTION
2 REPLIES 2
Reeza
Super User
Sure, import your Excel workbook and then you have that in a data set. You can pass the parameters to a macro call using CALL EXECUTE.

The CALL EXECUTE documentation has an example at the bottom that illustrates the idea.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 709 views
  • 0 likes
  • 3 in conversation