电子邮件ID来自于SAS中的SAS数据集

电子邮件ID来自于SAS中的SAS数据集

本文介绍了电子邮件ID来自于SAS中的SAS数据集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在电子邮件中发送SAS数据集的ID,但无法获取正确的格式。我只需要纯文本,因为HTML被卡住和缓慢。感谢提前协助!任何一个解决方案都会很好。

I'm trying to send out ID's of a SAS dataset in an email but not able to get the format right. I just need plain text as html is getting stuck and slow. Thanks in advance to help! Any one solution would be good.

我有一个ID列。第一个解决方案提供了一个完整的列表,如

I have one ID column. The first solution one gives a complete list like

%include "/saswrk/go/scripts/envsetup.sas";
filename mymail email "&emaillist."
subject="  &env. Records Transferred on %sysfunc(date(),yymmdd10.)";
data null;
set WORKGO.recds_processed;
file mymail;
put (_all_)(=);
run; quit;

输出

ID=1
ID=2
ID=3
ID=4
ID=5

如果我可以得到计数和输出,如
处理的记录数= 6,ID为1,2,3 ...

It would be nice if i could get the count and output likeNumber of records processed=6 and the ID's are 1,2,3...

推荐答案

尝试这样:

%include '/saswrk/go/scripts/envsetup.sas';

filename mymail email "&emaillist"
    subject = "&env Records Transferred on %sysfunc(date(), yymmdd10.)";

data _null_;
    length id_list $ 3000;
    retain id_list '';

    set workgo.recds_processed nobs = nobs end = eof;
    file mymail;

    if _n_ = 1 then do;
        put 'Number of records processed=' nobs;
        put 'The IDs are:';
    end;

    /* Print the IDs in chunks */
    if length(strip(id_list)) > 2000 then do;
        put id_list;
        call missing(id_list);
    end;

    call catx(', ', id_list, id);

    if eof then put id_list;
run;

在数据步骤的第一次迭代中,当 _n_ = 1 ,数据集中的观察次数将写入文件。

At the first iteration of the data step, when _n_ = 1, the number of observations in the dataset is written to the file.

然后,在每次迭代时,将当前ID追加到逗号分隔ID列表。当列表的长度超过2,000时,打印列表的内容,并将列表重置为空。这确保SAS字符串的最大长度永远不会达到,从而避免错误。

Then, at each iteration, the current ID is appended to a comma-separated list of IDs. When the length of the list exceeds 2,000, the contents of the list is printed and the list is reset to empty. This ensures that the maximum length of a SAS character string is never reached, thereby avoiding errors.

当达到输入数据集的结尾时,列表的当前内容输出。

When the end of the input dataset is reached, the current contents of the list is output.

这将为您提供多个逗号分隔的ID,其中每个块都用换行符分隔。

This will give you multiple chunks of comma-delimited IDs where each chunk is separated by a newline.

要从第二个数据集附加ID,您可以使用文件 mod 关键字来简单地修改现有文件>语句,并以其他相同的方式写入观察。

To append the IDs from a second dataset you can simply modify the existing file using the mod keyword in the file statement and write the observations in an otherwise identical manner.

data _null_;
    length id_list $ 3000;
    retain id_list '';

    set workgo.recds_not_processed nobs = nobs end = eof;
    file mymail mod;

    if _n_ = 1 then do;
        put 'Number of records not processed=' nobs;
        put 'The IDs are:';
    end;

    /* Print the IDs in chunks */
    if length(strip(id_list)) > 2000 then do;
        put id_list;
        call missing(id_list);
    end;

    call catx(', ', id_list, id);

    if eof then put id_list;
run;

这篇关于电子邮件ID来自于SAS中的SAS数据集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 00:56