请选择 进入手机版 | 继续访问电脑版
楼主: dxystata
852 3

[问答] 用macro实现重复 [推广有奖]

版主

大师

34%

还不是VIP/贵宾

-

TA的文库  其他...

Software

中英文Ebook

R学习

威望
2
论坛币
181698 个
通用积分
15202.5562
学术水平
208 点
热心指数
271 点
信用等级
174 点
经验
289856 点
帖子
5346
精华
1
在线时间
13444 小时
注册时间
2006-6-21
最后登录
2024-3-28

初级学术勋章 初级热心勋章

dxystata 发表于 2019-7-27 12:07:24 |显示全部楼层 |坛友微信交流群
20论坛币
  1. %macro  aaa(num=, style=);

  2. %put styles;
  3. %mend;
复制代码


num=5,style=l     styles为lllll
num=5,style=c    styles为ccccc
num=5,style=l2   styles为llccc
num=5,style=l3   styles为lllcc

谢谢!



最佳答案

洪哥得势1 查看完整内容

%macro repeat(num=,style=,num1=); data _null_; num=&num.; %if %length(&num1.)>0 %then %do; num1=&num1.; %end; %else %do; num1=&num.; %end; styles=substr(cats(repeat("&style.",num1-1),repeat("c",num-1)),1,num); call symput("styles",strip(styles)); run; %put ### styles=&styles.; %mend; %repeat(num=5, style=l, num1=); %repeat(num=5, style=c, num1=); %repeat(num=5, style=l, ...
关键词:Macro acr CRO Mac Styles
%macro repeat(num=,style=,num1=);
        data _null_;
                num=&num.;
                %if %length(&num1.)>0 %then %do; num1=&num1.; %end;
                %else %do; num1=&num.; %end;
                styles=substr(cats(repeat("&style.",num1-1),repeat("c",num-1)),1,num);
                call symput("styles",strip(styles));
        run;
        %put ### styles=&styles.;
%mend;

%repeat(num=5, style=l, num1=);
%repeat(num=5, style=c, num1=);
%repeat(num=5, style=l, num1=2);
%repeat(num=5, style=l, num1=3);

不知能否满足楼主的需求,仅供参考~
已有 1 人评分经验 学术水平 热心指数 收起 理由
dxystata + 100 + 1 + 2 分析的有道理

总评分: 经验 + 100  学术水平 + 1  热心指数 + 2   查看全部评分

使用道具

dxystata 发表于 2019-7-29 18:23:21 |显示全部楼层 |坛友微信交流群
洪哥得势1 发表于 2019-7-27 12:07
%macro repeat(num=,style=,num1=);
        data _null_;
                num=&num.;
谢谢!

使用道具

dxystata 发表于 2019-7-29 18:23:24 |显示全部楼层 |坛友微信交流群
洪哥得势1 发表于 2019-7-27 12:07
%macro repeat(num=,style=,num1=);
        data _null_;
                num=&num.;
谢谢!

使用道具

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

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

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

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