全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
10648 8
2015-08-31
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";

求解答,谢谢!


二维码

扫码加我 拉你入群

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

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

全部回复
2015-8-31 19:57:14
复制代码
二维码

扫码加我 拉你入群

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

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

2015-9-1 10:54:19
非常感谢,学习了,看了您的回复,一下子明白了,昨天纠结了一天,
二维码

扫码加我 拉你入群

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

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

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;

二维码

扫码加我 拉你入群

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

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

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

二维码

扫码加我 拉你入群

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

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

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

二维码

扫码加我 拉你入群

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

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

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群