proc sql输出

kpbwa7wx  于 2021-07-26  发布在  Java
关注(0)|答案(2)|浏览(324)

你好,我是sas的新手,我创建了sql代码,现在我需要将输出重定向到/tmp/output.txt。

proc sql;
select (COUNT(IDCUENTACLIENTE)) AS COUNT_of_IDCUENTACLIENTE from  S1.CUENTACLIENTE  where segmentonivel1  = 'Altas Recientes'
and segmentonivel2 = 'Masivo'
GROUP BY SEGMENTONIVEL1,SEGMENTONIVEL2;
quit;

我试着把

data _null_;
  FILE "/tmp/MyFile.txt";
run;

但没有创建文件。
有人能帮我吗?

7uzetpgm

7uzetpgm1#

我有个建议。。。首先使用查询创建一个数据集。在您的代码中,我对您使用的组有疑问。它运行没有错误?第二次导出到txt文件,如下所示

proc sql;
   create table work.temp as 
   select SEGMENTONIVEL1,SEGMENTONIVEL2, (COUNT(IDCUENTACLIENTE)) AS  
    COUNT_of_IDCUENTACLIENTE from  S1.CUENTACLIENTE  
   where segmentonivel1  = 'Altas Recientes'
   and segmentonivel2 = 'Masivo'
   GROUP BY SEGMENTONIVEL1,SEGMENTONIVEL2;
quit;
/* code to create TXT file  */
data _null_;
  FILE "/tmp/MyFile.txt";
  set work.temp;
  put 
     SEGMENTONIVEL1
     SEGMENTONIVEL2
     COUNT_of_IDCUENTACLIENTE;
run;
bcs8qyzn

bcs8qyzn2#

如果要使用文件名定义,但不想将文件名写入datastep:

proc sql;
    create table tableName as
        select (COUNT(IDCUENTACLIENTE)) AS COUNT_of_IDCUENTACLIENTE from  
        S1.CUENTACLIENTE  where segmentonivel1  = 'Altas Recientes'
            and segmentonivel2 = 'Masivo'
        GROUP BY SEGMENTONIVEL1,SEGMENTONIVEL2;
quit;

filename x "c:\temp\teszt.txt";

data _null_;
 file x;
 set work.tableName;
 put COUNT_of_IDCUENTACLIENTE;
run;

相关问题