You'll need some macro quoting to mask the & so that the macro processor doesn't try to resolve the macro variable BANQUE.
The error about column BANQUE not existing is because your PROC SQL step reads in get_base_url, which doesn't have the BANQUE column in it.
For this simple example where you have one record in both datasets, the code would work if the SQL step joins get_base_url and get_table_finale1:
data get_base_url ;
format HTTPS $50. ;
format appli $10. ;
appli = 'GEC' ;
HTTPS = "https://gec0-kf.compagny.fr/CONSULTATION/?mnc=GEC" ;
output ;
run ;
%macro mv_calcul_url(p_appli, p_banque) ;
%local rc url_definie ;
%let url_definie = ;
%let rc=%sysfunc(dosubl(%nrstr(
proc sql noprint ;
select
cats(HTTPS,"%nrstr(&banque)=",&p_banque) into :url_renvoye
from get_base_url,get_table_finale1
where appli = "&p_appli"
;
quit ;
))) ;
%superq(url_renvoye)
%mend mv_calcul_url;
data get_table_finale1 ;
banque = '14940' ;
output ;
run ;
data want_table_finale2 ;
set get_table_finale1 ;
url_gec = "%mv_calcul_url(GEC,banque)";
run ;
While I'm a fan of the macro language and DOSUBL, depending on the big picture, it's possible you could get what you want with just a SQL query, without the nee to build a function-style macro, e.g.:
proc sql noprint ;
create table want as
select
banque
,cats(HTTPS,"%nrstr(&banque)=",banque) as url_gec
from get_base_url,get_table_finale1
where appli = "GEC"
;
quit ;
... View more