楼主: dxystata
2270 3

如何通过macro得到数据集 [推广有奖]

版主

已卖:302份资源

大师

37%

还不是VIP/贵宾

-

TA的文库  其他...

Software

中英文Ebook

R学习

威望
2
论坛币
183395 个
通用积分
15333.1475
学术水平
208 点
热心指数
271 点
信用等级
174 点
经验
298627 点
帖子
5586
精华
1
在线时间
13632 小时
注册时间
2006-6-21
最后登录
2025-12-22

初级学术勋章 初级热心勋章 中级热心勋章 初级信用勋章

楼主
dxystata 发表于 2013-12-25 07:07:30 |AI写论文
100论坛币
  1. data aaa;
  2. attrib x1 label='group';
  3. attrib x2 label='sex';
  4. attrib a  label='age';
  5. attrib b  label='weight';
  6. input x1 x2 a b@@;
  7. cards;
  8. 1 2 23 60
  9. ;
  10. run;
复制代码
%macro (vars=x1 x2 x1*b x1*x2 b);




%mend;

如何通过macro得到数据集
k varible vlabel
1   x1    group
2   x2    sex
3   x1*b  group×weight
4   x1*x2 group×sex
5   b       weight

谢谢!

关键词:Macro CRO acr Mac 数据集 如何

本帖被以下文库推荐

沙发
邓贵大 发表于 2013-12-25 07:07:31
  1. data aaa;
  2. attrib x1 label='group';
  3. attrib x2 label='sex';
  4. attrib a  label='age';
  5. attrib b  label='weight';
  6. input x1 x2 a b@@;
  7. cards;
  8. 1 2 23 60
  9. ;
  10. %macro a(vars=x1 x2 x1*b x1*x2 b);
  11. data bbb;
  12.         if 0 then set aaa;

  13.         do k=1 to countw("&vars", " ");
  14.                 length variable $ 32 vlabel $ 255;
  15.                 variable = scan("&vars", k, ' ');
  16.                 vlabel = ' ';
  17.                 do _n_=1 to countw(variable, '*');
  18.                         vlabel = catx('×', vlabel, vlabelx(scan(variable,_n_,'*')));
  19.                 end;
  20.                 output;
  21.         end;
  22.         stop;
  23.         keep k variable vlabel;
  24. run;
  25. %mend;
  26. %a;
复制代码
已有 2 人评分经验 学术水平 热心指数 信用等级 收起 理由
dxystata + 100 + 5 + 5 + 5 精彩帖子
Tigflanker + 1 + 1 + 1 热心帮助其他会员

总评分: 经验 + 100  学术水平 + 6  热心指数 + 6  信用等级 + 6   查看全部评分

Be still, my soul: the hour is hastening on
When we shall be forever with the Lord.
When disappointment, grief and fear are gone,
Sorrow forgot, love's purest joys restored.

藤椅
dxystata 发表于 2013-12-26 18:24:11
邓贵大 发表于 2013-12-25 07:07
如果变量的label是空,用变量名代替。比如x2的label为空  则x1*x2  为group×x2

板凳
邓贵大 发表于 2013-12-27 00:41:52
dxystata 发表于 2013-12-26 18:24
如果变量的label是空,用变量名代替。比如x2的label为空  则x1*x2  为group×x2
replace
  1. vlabel = catx('×', vlabel, vlabelx(scan(variable,_n_,'*')));
复制代码
with
  1. vlabel = catx('×', vlabel, coalescec(vlabelx(scan(variable,_n_,'*')), scan(variable,_n_,'*')));
复制代码
已有 1 人评分经验 学术水平 热心指数 信用等级 收起 理由
dxystata + 50 + 1 + 1 + 1 分析的有道理

总评分: 经验 + 50  学术水平 + 1  热心指数 + 1  信用等级 + 1   查看全部评分

Be still, my soul: the hour is hastening on
When we shall be forever with the Lord.
When disappointment, grief and fear are gone,
Sorrow forgot, love's purest joys restored.

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-25 12:53