我的目的是把有共同字符串的那一行保留下来,如returnloser1有JPYvsUSD_ER_FM的话,因为含有共同字符串JPYvsUSD,则保留下来。我用宏变量赋值给abc分别比对错误,然后发现a的结果最接近,log上表示trim(JPYvsUSD_ER_FM),那如何出去trim呢? 本来预期的结果是JPYvsUSD_ER_FM的。。。
%Macro ReEaPeriod(m,n);/*to get the currency pair in each month,m-loser/winner,n-1,2,3...*/
PROC transpose DATA=&m&n OUT=TransEachCurrency&m&n name=Time;/*transpose each ranking result by date*/
ID Currency;/*copy the former variable name*/
RUN;
proc contents data=work.TransEachCurrency&m&n/*eg.TransEachCurrencyloser1,after transpose of loser1*/
out=abc/*(drop=Currency)*/
noprint;
run;
proc sql noprint;
select distinct name
into :Firstcurrency separated by ' '
from abc
where varnum in (2)/*choose the 2nd variable*/
order by varnum;
quit;
proc contents data=work.TransEachCurrency&m&n/*eg.TransEachCurrencyloser1,after transpose of loser1*/
out=abcd/*(drop=Currency)*/
noprint;
run;
proc sql noprint;
select distinct name
into :Secondcurrency separated by ' '
from abcd
where varnum in (3)/*choose the 3th variable*/
order by varnum;
quit;
proc contents data=work.TransEachCurrency&m&n
out=abcde
noprint;
run;
proc sql noprint;
select distinct name
into :Thirdcurrency separated by ' '
from abcde
where varnum in (4)/*choose the ith variable*/
order by varnum;
quit;
%let a=%sysfunc(%trim(%Substr(&Firstcurrency,1,8)_er_fm);
%let b=%str(")%sysfunc(%trim(%Substr(&Secondcurrency,1,8))%str(_er_fm");
%let c=%trim(%Substr(&Thirdcurrency,1,8)_er_fm);
%Monthreturn(returnLoser);
%Monthreturn(returnWinner);
data returnloser1;
求大神支招



雷达卡


京公网安备 11010802022788号







