请选择 进入手机版 | 继续访问电脑版
楼主: yaniwei1314
3112 11

SAS怎么将一个宏变量分成指定变量个数的N个小宏变量啊? [推广有奖]

jingju11 发表于 2015-11-3 11:11:21 |显示全部楼层 |坛友微信交流群
JingJu11: My classmate provided the following code
  1. %macro test(var, n);
  2.         %local k c i j;
  3.         %let k=0;
  4.         %let c=%sysfunc(countw(&var%str( )));
  5.         %do i =1 %to &n;
  6.                 %let var&i=;
  7.                 %do j=1 %to %sysevalf((&c-&k)/(&n+1-&i), c);
  8.                         %let k =%eval(&k +1);
  9.                         %let var&i =&&var&i %scan(&var, &k);
  10.                         %end;        %put var&i:&&var&i;
  11.                 %end;
  12. %mend test;
  13. %test(1 2 3,3)
复制代码

使用道具

jingju11 发表于 2015-11-4 07:58:26 |显示全部楼层 |坛友微信交流群
jingju11 发表于 2015-11-3 11:11
JingJu11: My classmate provided the following code
Some people raised a question to my friend: Any pros and cons on programming on pure macro syntax vs. using some other interfaces, such as data step or procedures? The answer is: if you can program on pure macro syntax, you should do it. Because you can place the code anywhere you want; on the other hand, doing macro programming on data step or procedures can only work wherever it is suitable. It usually works as an independent function-like unit. The bad thing for macro syntax programming is that always is hindered and complicated by macro variable masking scheme.
JingJu

使用道具

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

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-3-29 17:08