- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 SAS 中有一些数据集,我试图将它们整理成一个更大的数据集,稍后我将对其进行过滤。它们都被称为 table_201802
。我的问题是缺少几个月(即存在 table201802
和 table201804
及以上,但不存在 table201803
。
我对 SAS 还不够陌生,但到目前为止我尝试的是创建一个名为 output testing
的新数据集并运行一个宏循环迭代名称(它们来自 201802
到 201903
,它们是月度数据,因此从 812 到 900 的任何数据都不存在)。
data output_testing;
set
%do i=802 %to 812;
LIBRARY.table_201&i
%end;
;
run;
%mend append;
我希望代码忽略丢失的表,只查找确实存在的表,然后将它们附加到新的 output_testing
表中。
最佳答案
如果表名前缀不同,并且您确信表中的数据结构是一致的(变量名称、类型和长度相同),则可以使用表名前缀列表(:
)
对于特定的已知范围的表名,您还可以使用编号范围列表 (-
) 选项卡
data have190101 have190102 have190103;
x =1;
run;
data want_version1_stack; /* any table name that starts with have */
set have:;
run;
data want_version1b_stack; /* 2019 and 2020 */
set have19: have20:;
run;
options nodsnferr;
data want_version2_stack; /* any table names in the iterated numeric range */
set have190101-have191231;
run;
options dsnferr;
来自 helps
Using Data Set Lists with SET
You can use data set lists with the SETstatement. Data set lists provide a quick way to reference existinggroups of data sets. These data set lists must either be name prefixlists or numbered range lists.Name prefix lists refer to all datasets that begin with a specified character string. For example, setSALES1:; tells SAS to read all data sets that start with "SALES1" suchas SALES1, SALES10, SALES11, and SALES12. >
Numbered range listsrequire you to have a series of data sets with the same name, exceptfor the last character or characters, which are consecutive numbers.In a numbered range list, you can begin with any number and end withany number. For example, these lists refer to the same data sets:
- sales1 sales2 sales3 sales4
- sales1-sales4
关于sas - 遍历名称时有没有办法跳过丢失的数据集?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56931747/
我是一名优秀的程序员,十分优秀!