楼主: anzhiliang
3149 7

如何写程序判断一个数据集里是否有一个固定的变量? [推广有奖]

  • 0关注
  • 0粉丝

博士生

38%

还不是VIP/贵宾

-

威望
0
论坛币
1240 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
2027 点
帖子
136
精华
0
在线时间
410 小时
注册时间
2009-8-21
最后登录
2022-5-2

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
如何写程序判断一个数据集里是否有一个固定的变量?
二维码

扫码加我 拉你入群

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

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

关键词:如何写 数据集 变量

回帖推荐

pobel 发表于5楼  查看完整内容

*** Provide the variable you want to check; %let vartest=weight; *** Open dataset; %let dsid=%sysfunc(open(sashelp.class)); *** Get the position of the test variable; %let varnum=%sysfunc(varnum(&dsid,&vartest)); *** If the position is not 0, then the variable exists in the dataset; %put The number of the position of variable &vartest: &varnum; *** Close the dataset; %let rc=%sysf ...

本帖被以下文库推荐

MSN:anzhiliang1@hotmail.com
努力做个好人。
沙发
Irislu 发表于 2010-7-19 16:06:19 |只看作者 |坛友微信交流群
进来看看而已

使用道具

藤椅
pobel 在职认证  发表于 2010-7-19 16:19:30 |只看作者 |坛友微信交流群
%let vartest=weight;
%let dsid=%sysfunc(open(sashelp.class));

%put %sysfunc(ifc(%sysfunc(varnum(&dsid,&vartest))
                   ,Variable &vartest exists in the dataset!
                   ,Variable &vartest does not exist in the dataset!));
%let rc=%sysfunc(close(&dsid));
和谐拯救危机

使用道具

板凳
anzhiliang 发表于 2010-7-19 16:24:57 |只看作者 |坛友微信交流群
3# pobel


高手您能注释一下吗?我是菜鸟有些东西还看不懂,谢谢!
MSN:anzhiliang1@hotmail.com
努力做个好人。

使用道具

报纸
pobel 在职认证  发表于 2010-7-19 16:31:29 |只看作者 |坛友微信交流群
*** Provide the variable you want to check;
%let vartest=weight;

*** Open dataset;
%let dsid=%sysfunc(open(sashelp.class));

*** Get the position of the test variable;
%let varnum=%sysfunc(varnum(&dsid,&vartest));

*** If the position is not 0, then the variable exists in the dataset;
%put The number of the position of variable &vartest: &varnum;

*** Close the dataset;
%let rc=%sysfunc(close(&dsid));
已有 1 人评分经验 论坛币 收起 理由
bakoll + 3 + 3 精彩帖子

总评分: 经验 + 3  论坛币 + 3   查看全部评分

和谐拯救危机

使用道具

地板
soporaeternus 发表于 2010-7-19 16:31:30 |只看作者 |坛友微信交流群
走查询元数据表应该也可以吧
Let them be hard, but never unjust

使用道具

7
anzhiliang 发表于 2010-7-19 16:44:38 |只看作者 |坛友微信交流群
5# pobel




Thank you very much !you are so kind.......
MSN:anzhiliang1@hotmail.com
努力做个好人。

使用道具

8
pobel 在职认证  发表于 2010-7-19 17:08:00 |只看作者 |坛友微信交流群
soporaeternus 发表于 2010-7-19 16:31
走查询元数据表应该也可以吧
没错,查询元数据表也行。

proc sql;
    select count(*) into : exist
  from dictionary.columns
  where libname="SASHELP" and MEMNAME="CLASS" and NAME="Weight";
quit;

%put ∃
和谐拯救危机

使用道具

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

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

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

GMT+8, 2024-4-28 21:30