循环计算表中的记录数。

huangapple go评论74阅读模式
英文:

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

enter image description here

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;

huangapple
  • 本文由 发表于 2023年7月14日 02:37:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/76682355.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定