楼主: 168lijijie
9538 8

[程序分享] SAS中,如何判断一个变量a的值是否存在于某些变量中 [推广有奖]

  • 0关注
  • 0粉丝

大专生

50%

还不是VIP/贵宾

-

威望
0
论坛币
1 个
通用积分
0.0042
学术水平
0 点
热心指数
1 点
信用等级
0 点
经验
876 点
帖子
28
精华
0
在线时间
45 小时
注册时间
2009-12-19
最后登录
2019-10-9

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
SAS中,现在我想判断我的一个变量a的值是否存在于某数组中或者说存在于某些变量中,不用循环,一句话搞定的~求大神解答~
例:针对 如下数据集:
data a1;
        x1=2;x2=3;x3=4;x5=6;a=4;
run;

如何判断a的值在不在变量x1-x5中,如果在将变量名赋值为a_name,即得到新的数据集a2为x1=2;x2=3;x3=4;x5=6;a=4;a_name="x3";

求解答,谢谢!


二维码

扫码加我 拉你入群

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

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

关键词:name Data 数据集 一句话 求解答 如何

回帖推荐

已有 1 人评分热心指数 收起 理由
eijuhz + 1 精彩帖子

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

本帖被以下文库推荐

沙发
18129380375 学生认证  发表于 2015-8-31 19:57:14 |只看作者 |坛友微信交流群
  1. data a1;
  2. input x1 x2 x3 x5 a;
  3. cards;
  4. 2 3 4 6 4
  5. run;

  6. data a2;
  7. set a1;
  8. array array{*} x1 x2 x3 x5;
  9. do i=1        to dim(array);
  10.     if array(i)=a then
  11.         output;
  12. end;
  13. run;
复制代码
已有 1 人评分学术水平 热心指数 信用等级 收起 理由
Tigflanker + 2 + 3 + 1 分析的有道理

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

使用道具

藤椅
168lijijie 发表于 2015-9-1 10:54:19 |只看作者 |坛友微信交流群
非常感谢,学习了,看了您的回复,一下子明白了,昨天纠结了一天,

使用道具

板凳
teqel 发表于 2015-9-1 22:47:25 |只看作者 |坛友微信交流群
18129380375 发表于 2015-8-31 19:57
do i=1        to dim(array);

    if array(i)=a then do;

        a_name=vname(x(i));
        leave;
end;

end;

已有 1 人评分学术水平 热心指数 信用等级 收起 理由
Tigflanker + 2 + 3 + 1 分析的有道理

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

使用道具

报纸
168lijijie 发表于 2015-9-2 12:08:00 |只看作者 |坛友微信交流群
谢谢楼上,vname函数学习了,太厉害了,顺便提一下其它函数,以便以后参考:
1.Functions That Determine SAS Variable Information :
VTYPE,VTYPEX:To determine if a variable is character or numeric.
VLENGTH:        To return the storage length (determined at compile time) for a variable
VNAME:           To return the name of a SAS variable
VLABEL:           To return the label associated with a SAS variable
CALL VNEXT:    To determine the name, type, and length of one or more DATA step variables
VVALUE :         To obtain the formatted value of a variable

使用道具

地板
168lijijie 发表于 2015-9-2 12:12:53 |只看作者 |坛友微信交流群

2.Functions That Determine Format Information 403
VFORMAT :     To return the format name associated with a variable
VFORMATD :   To return the format decimal value associated with a variable
VFORMATN :   To return the format name associated with a variable. The name includes the $ if the format is a character variable, but not the width of the decimal value.

VFORMATW :  To return the format width associated with a variable

使用道具

7
168lijijie 发表于 2015-9-2 12:13:24 |只看作者 |坛友微信交流群

3.Functions That Determine Informat Information
VINFORMAT :   To return the informat name associated with a variable
VINFORMATD:  To return the informat decimal value associated with a variable
VINFORMATN:  To return the informat name associated with a variable. The name includes the $ if the informat is associated with a character variable, but not the width of the decimal value.

VINFORMATW:  To return the informat width associated with a variable

使用道具

8
liushui 在职认证  发表于 2018-4-29 08:40:53 |只看作者 |坛友微信交流群
学习了,谢谢

使用道具

9
长似初相识 学生认证  发表于 2022-12-4 10:36:39 |只看作者 |坛友微信交流群
学习了,谢谢

使用道具

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

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

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

GMT+8, 2024-4-27 13:03