楼主: 若水烟寒
7581 16

_all_应该怎么查看和使用? [推广有奖]

  • 3关注
  • 9粉丝

已卖:840份资源

博士生

8%

还不是VIP/贵宾

-

威望
0
论坛币
1391 个
通用积分
33.0863
学术水平
14 点
热心指数
18 点
信用等级
12 点
经验
2716 点
帖子
183
精华
0
在线时间
176 小时
注册时间
2011-5-11
最后登录
2025-6-4

楼主
若水烟寒 发表于 2012-11-10 18:59:31 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
_all_表示所有变量的名称,但是我要怎么查看和使用呢?
比如说想统计一下变量的个数,应该怎么操作呢?谢谢!
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:怎么操作 统计

回帖推荐

davil2000 发表于9楼  查看完整内容

/*If you use _ALL_, all the previously defined variables must be of the same type.*/ data _null_; set sashelp.prdsale(obs=1); array _allvar_(*) _numeric_; array _allvar2_(*) _character_ ; do i=1 to dim(_allvar_); vname=vname(_allvar_(i)); put vname=; end; do i=1 to dim(_allvar2_); vname2=vname(_allvar2_(i)); put vname2=; end; run; %macro name; data _null_; set s ...
已有 1 人评分经验 论坛币 学术水平 热心指数 信用等级 收起 理由
数据分析师3K + 60 + 20 + 1 + 1 + 1 Goog question

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

本帖被以下文库推荐

沙发
davil2000 发表于 2012-11-10 19:14:42
These option has many function.
For example, "put _ALL_ "writes the values of all variables, which includes automatic variables, that are defined in the current DATA step by using named output.

data a;
do i= 1 to 5;
x=sqrt(i);
output;
put _all_;
end;
run;
R是万能的,SAS是不可战胜的!

藤椅
若水烟寒 发表于 2012-11-10 19:37:41
davil2000 发表于 2012-11-10 19:14
These option has many function.
For example, "put _ALL_ "writes the values of all variables, which ...
谢谢!那应该怎么统计有多少个变量呢?(不含自动变量……)
本来是想在宏里面用dim(array)来统计的……结果后来发现宏里面不能用array啊……
https://bbs.pinggu.org/forum.php? ... =2130886&extra=

板凳
davil2000 发表于 2012-11-10 20:03:55
若水烟寒 发表于 2012-11-10 19:37
谢谢!那应该怎么统计有多少个变量呢?(不含自动变量……)
本来是想在宏里面用dim(array)来统计的…… ...
really?

%macro name;
data _null_;
array r(2) x y (1,2);
put _all_;
put 'r(1)='r(1) ' r(2)='r(2);
run;
%mend name;
%name;
已有 1 人评分热心指数 收起 理由
南海游客 + 2 热心帮助其他会员

总评分: 热心指数 + 2   查看全部评分

R是万能的,SAS是不可战胜的!

报纸
obertan 发表于 2012-11-10 20:10:51
在ODS中也可以用_all_来关闭所有输出方式,如 ods _all_ close;

地板
davil2000 发表于 2012-11-10 20:18:12
data _null_;
   dsid=open("sashelp.prdsale");
   xxx=attrn(dsid,"nvars");
   put  "the number of variables is " xxx;
run;
已有 2 人评分经验 论坛币 学术水平 热心指数 信用等级 收起 理由
数据分析师3K + 60 + 20 + 5 + 5 + 5 热心帮助其他会员
若水烟寒 + 1 + 1 + 1 热心帮助其他会员

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

R是万能的,SAS是不可战胜的!

7
若水烟寒 发表于 2012-11-10 21:37:19
davil2000 发表于 2012-11-10 20:03
really?

%macro name;
I'm sorry, but I can't apply the dim() function in the macro. I can't figure out why. Would you help me to solve this problem? I'm a green hand in this area and I can't thank you more^^
data _null_;
set d1;
array  _allvar_(*) _all_;
do i=1 to dim(_allvar_);
vname=vname(_allvar_(i));
put vname=;
end;
run;



%macro name;
data d1;
set d1;
array  _allvar_(*) _all_;
%do i=1 %to dim(_allvar_);
vname=vname(_allvar_(i));
put vname=;
%end;
run;
%mend name;
%name;

The error is:

ERROR: 需要的操作符在以下表达式中没有找到: dim(_allvar_)
ERROR: %TO 值(%DO I 循环中)无效。
ERROR: 宏 NAME 将终止执行。

8
若水烟寒 发表于 2012-11-10 21:45:39
davil2000 发表于 2012-11-10 19:14
These option has many function.
For example, "put _ALL_ "writes the values of all variables, which ...
Actually, my attempt was to change the names of a dataset to v1-v5. The original names may not follow a fornula, for example, like  "id name age address phone" and so on. How can I program it by the macro method? Thank you !

9
davil2000 发表于 2012-11-11 08:43:04
若水烟寒 发表于 2012-11-10 21:37
I'm sorry, but I can't apply the dim() function in the macro. I can't figure out why. Would you he ...
/*If you use _ALL_, all the previously defined variables must be of the same type.*/
data _null_;
set sashelp.prdsale(obs=1);
array  _allvar_(*) _numeric_;
array  _allvar2_(*) _character_ ;
do         i=1 to dim(_allvar_);
                vname=vname(_allvar_(i));
                put vname=;
end;
do         i=1 to dim(_allvar2_);
                vname2=vname(_allvar2_(i));
                put vname2=;
end;
run;



%macro name;
data _null_;
set sashelp.prdsale(obs=1);
array  _allvar_(*) _numeric_;
array  _allvar2_(*) _character_ ;
do         i=1 to dim(_allvar_);
                vname=vname(_allvar_(i));
                put vname=;
end;
do         i=1 to dim(_allvar2_);
                vname2=vname(_allvar2_(i));
                put vname2=;
end;
run;
%mend name;
%name;
已有 2 人评分经验 论坛币 学术水平 热心指数 信用等级 收起 理由
南海游客 + 5 + 5 + 5 分析的有道理
数据分析师3K + 60 + 20 + 5 + 5 + 5 热心帮助其他会员

总评分: 经验 + 60  论坛币 + 20  学术水平 + 10  热心指数 + 10  信用等级 + 10   查看全部评分

R是万能的,SAS是不可战胜的!

10
若水烟寒 发表于 2012-11-11 16:09:22
davil2000 发表于 2012-11-11 08:43
/*If you use _ALL_, all the previously defined variables must be of the same type.*/
data _null_; ...
Thank you very much! But I don't understand why I can't use functions like dim() in the macro loop "%do %to %end". For example, I want to use some macro variables like "&***" in the loop, but at the same time such useful functions are not available for me. In this situation I can't replace it for the data loop. What can I do and how these functions can be used on that condition?

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

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