SAS 检查表中是否存在列
我想制作一个宏来检查 col_to_check 中的所有列是否都在表中,并且如果其中一列不退出,我想退出 SAS
我尝试这样做:
%let col_to_check = ID SEG AGE;
%宏检查(表,col_to_check);
%local count;
%let count=0;
%DO i_=1 %TO %sysfunc(countw(&col_to_check.," "));
%LET col=%SCAN(&col_to_check.,&i_.," ");
%if ( %varexist(&table.,&col.) = 1) %then endsas;
%END;
%修复检查;
I want to make a macro That check if all the columns in col_to_check are in Table and I want exit SAS if one of these columns doesn't exit
I try this:
%let col_to_check = ID SEG AGE;
%MACRO check(table , col_to_check);
%local count;
%let count=0;
%DO i_=1 %TO %sysfunc(countw(&col_to_check.," "));
%LET col=%SCAN(&col_to_check.,&i_.," ");
%if ( %varexist(&table.,&col.) = 1) %then endsas;
%END;
%MEND check;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
sashelp
库的vcolumn
表。PS:“退出 SAS”是什么意思?您可以轻松地将
%goto
替换为 %ABORT< /a>Use the
vcolumn
table of thesashelp
library.PS: What do you mean by "exit SAS"? You could easily replace the
%goto
by %ABORT