楼主: caibirdcnb
4104 25

[原创博文] 请问高手如何组合N个宏变量名,谢谢! (还没解决啊) [推广有奖]

21
zfpg 发表于 2011-11-7 23:31:13
学习

22
bobguy 发表于 2011-12-5 00:33:41
Here is a solution. Assume you know the prefix of a list of macro variables.


proc sql noprint;
select name into : vlist separated by ' '
from dictionary.macros
where scope='GLOBAL' and (name like 'L%' or name like 'W%')
order by 1
;
quit;

%SYMDEL &vlist;

%put _all_;


***create some macro variables***;
data _null_;
  n=ceil(10*ranuni(-1));
  do i=1 to n;
   call symputx(catt('L',i), i);
  end;
  n=ceil(10*ranuni(-1));
  do i=1 to n;
   call symputx(catt('W',i), i);
  end;
run;

***make a variable w/ prefix into a list;
proc sql noprint;
select name into : vlistL separated by ' '
from dictionary.macros
where scope='GLOBAL' and name like 'L%'
order by 1
;
quit;

%put >>>>&vlistL<<<<;


***make a variable w/ prefix into a list;
proc sql noprint;
select name into : vlistW separated by ' '
from dictionary.macros
where scope='GLOBAL' and name like 'W%'
order by 1
;
quit;

%put >>>>&vlistL<<<< >>>>&vlistW<<<<;

23
caibirdcnb 发表于 2011-12-5 08:11:24
非常感谢!bobguy!

24
dreamllian 发表于 2011-12-6 13:47:28
学习了

25
sanbao85110 发表于 2012-3-13 16:53:25
学习了……………………

26
tanzhijun 发表于 2012-3-13 17:16:19
学习了……………………
去阅读,去写作,去热恋

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-2 03:38