英文:
Loop to Count how many records in the table
问题
我在想是否有一种方法可以在循环中计算表名以G结尾的卷数,并将其命名为表名,例如output_dps_BCS_FT_G。
我只是想知道是否有一种有效的方法来完成这个任务,而不是手动逐个完成。
英文:
I was wondering whether there’s a way to count the volume where the table name end with G in a loop and name it as the table name e.g output_dps_BCS_FT_G
I’m just wondering whether there is a efficient way of doing it rather than manually doing it one by one.
答案1
得分: 0
一种方法是使用SAS字典表,这些表存储了有关所有定义库中数据集的元数据。您可能希望添加一个WHERE子句来将其限制为您感兴趣的库。类似以下的代码:
proc sql ;
select libname,memname,nlobs from dictionary.tables
where memname like '%G'
;
quit ;
要将结果输出到SAS数据集,您可以添加一个CREATE TABLE子句,例如:
proc sql ;
create table G_Tables as
select libname, memname as Filename, nlobs as Count
from dictionary.tables
where memname like '%G'
;
quit ;
proc print data=G_Tables;
run;
请注意,代码部分不需要翻译。
英文:
One approach is to use SAS dictionary tables, which store metadata about all datasets in defined libraries. You would likely want to add a WHERE clause to limit this to the libraries of interest to you. Code like:
proc sql ;
select libname,memname,nlobs from dictionary.tables
where memname like '%G'
;
quit ;
To output the results to a SAS dataset, you can add a CREATE TABLE clause, e.g.:
proc sql ;
create table G_Tables as
select libname, memname as Filename, nlobs as Count
from dictionary.tables
where memname like '%G'
;
quit ;
proc print data=G_Tables;
run;
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论