gpt4 book ai didi

sas - 在sas中设置具有相似名称的多个数据集

转载 作者:行者123 更新时间:2023-12-05 01:47:14 24 4
gpt4 key购买 nike

假设我的工作环境中有不同数量的数据集,但所有这些数据集都以相似的名称开头:name_abc、name_efg、name_1ky 等。这些数据集具有相同的变量和特征,我想将它们全部设置到一个数据集中。

data bigdataset;
set [all datasets that begin with name_];
run;

有没有一种方法可以在 SAS 中执行此操作而无需键入所有数据集?我需要它能够灵活处理工作环境中可用的数据集数量。

最佳答案

使用变量名通配符:

data bigdataset;
set name_:;
run;

A colon following a variable name prefix selects any variable whose name starts with that prefix. This ability of the colon along with some simple naming standards enables the programmer to manage temporary variables better, format many variables quicker, determine unknown number of variables, clean up macro generated datasets, and shorten the code for variety of PROCS. For example

data ADLB;
set lb:;

This DATA step reads all the data sets in the WORK library that begin with LB. Also, when the programmer coded this step, he/she did not need to know how many dataset are read, only that he/she wants to read all of the dataset with a particular prefix. Both colon and dash lists also work with the MERGE statement.

引自Using SAS Colon Effectively

关于sas - 在sas中设置具有相似名称的多个数据集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29547038/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com