Hi,
Seeking for a help to build that into working macro.
Case when orig_nm LIKE '%KRAKEN%' then orig_acct_id
when benef_nm LIKE '%KRAKEN%' then benef_acct_id
when scnd_orig_nm LIKE '%KRAKEN%' then scnd_orig_acct_id
when scnd_benef_nm LIKE '%KRAKEN%' then scnd_benef_acct_id
when orig_nm LIKE '%BINANCE%' then orig_acct_id
when benef_nm LIKE '%BINANCE%' then benef_acct_id
when scnd_orig_nm LIKE '%BINANCE%' then scnd_orig_acct_id
when scnd_benef_nm LIKE '%BINANCE%' then scnd_benef_acct_id
Generally the list of crypto platforms in LIKE is huge and dynamic, so I don't want to repeat "when" 300 times and then modify it once I add new entities. I would like a macro that pulls platforms names out of my list search for it in "orig_nm", "benef_nm" etc. and once it finds it, it assigns a value from corresponding acct number fields within the same records.
So I create one variable that holds account numbers for crypto platforms, wherever it finds it. Is there anyone who possibly could help with this?
In an earlier thread on this subject, you marked an answer that showed how to do this as the correct answer: https://communities.sas.com/t5/SAS-Programming/macro-with-a-list-of-strings-from-table/m-p/782195#M2...
Show us what you have tried.
Give us a partial list of these crypto platforms
Give us a partial list of the variable names
Tried this but didn't succeed. Then tried to change this part "%let field=%scan(&fields,&i);" to "%let field=%scan(&fields,&j);" - didn't succeed either. However, I got help on my old thread. So I got a solution already 🙂
%macro new_loop(texts,
fields=ORIG_NM BENEF_NM SCND_ORIG_NM SCND_BENEF_NM SEND_INSTN_NM);
%local i j like_str text;
%let texts=%upcase(&texts);
%do i=1 %to %sysfunc(countw(&texts));
%let text=%scan(&texts,&i);
%let field=%scan(&fields,&i);
%let like_str=%unquote(%nrstr(%'%%)&text%nrstr(%%%'));
when upper(%scan(&fields,1)) like &like_str
%do j=2 %to %sysfunc(countw(&fields));
or upper(%scan(&fields,&j)) like &like_str
%end;
then %sysfunc(quote(&field,%str(%')))
%put _local_;
%end;
%mend;
That's good news you got a solution.
As a tip for the future, saying “didn't succeed” with no other explanation never works.
We need to see the LOG, if there are errors in the log; or we need to see the incorrect output. And an explanation of “didn't succeed” is almost always helpful.
Thank you!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.