使用SAS数据集成(DI)Studio开发ETL程序时,您指定的每个转换都有一个用户界面,用于指定您创建的数据集(=表)的列及其类型,长度和格式。
当现有转换无法完成工作并且需要用户编写代码时,您应该使用点击式界面尽可能多地执行此操作,因为
幸运的是,SAS向宏程序变量的用户编写转换的程序员公开了输出的格式
所以我经常在用户编写的转换中编写我的代码
%macro format_output(data);
%do _col = 0 %to &&&data._col_count - 1;
length &&&data._col&_col._name &&&data._col&_col._type&&&data._col&_col._length;
%if %length(&&&data._col&_col._format) %then %do;
format &&&data._col&_col._name &&&data._col&_col._format;
%end;
%end;
%mend;
data &_OUTPUT1 (keep=&_OUTPUT1_keep);
%format_output(_OUTPUT1);
set &_INPUT1;
* actua code ;
run;
对于完整性:SAS公开输出结构的方式如下
%let _OUTPUT1 = myLib.myTable;
%let _OUTPUT1_connect = ;
%let _OUTPUT1_engine = ;
%let _OUTPUT1_memtype = DATA;
%let _OUTPUT1_options = %nrquote();
%let _OUTPUT1_alter = %nrquote();
%let _OUTPUT1_path = %nrquote(/myTable_A5E5JYT6.C7000MOL%(WorkTable%));
%let _OUTPUT1_type = 1;
%let _OUTPUT1_label = %nrquote();
/* List of target columns to keep */
%let _OUTPUT1_keep = myID first_item <16 more items> last_item;
%let _OUTPUT1_col_count = 19;
%let _OUTPUT1_col0_name = myID;
%let _OUTPUT1_col0_table = myLib.myTable;
%let _OUTPUT1_col0_length = 8;
%let _OUTPUT1_col0_type = ;
%let _OUTPUT1_col0_format = 13.;
%let _OUTPUT1_col0_informat = 13.;
%let _OUTPUT1_col0_label = %nrquote(my ID);
%let _OUTPUT1_col0_input0 = myID;
%let _OUTPUT1_col0_exp = ;
%let _OUTPUT1_col0_input = myID;
%let _OUTPUT1_col0_input_count = 1;
%let _OUTPUT1_col1_name = first_item;
%let _OUTPUT1_col1_table = myLib.myTable;
%let _OUTPUT1_col1_length = 8;
%let _OUTPUT1_col1_type = $;
%let _OUTPUT1_col1_format = $CHAR8.;
%let _OUTPUT1_col1_informat = $CHAR8.;
%let _OUTPUT1_col1_label = %nrquote(first data item in my table);
%let _OUTPUT1_col1_input0 = first_item;
%let _OUTPUT1_col1_exp = ;
%let _OUTPUT1_col1_input = first_item;
%let _OUTPUT1_col1_input_count = 1;
<documentation about 16 more columns>
%let _OUTPUT1_col18_name = last_item;
%let _OUTPUT1_col18_table = myLib.myTable;
%let _OUTPUT1_col18_length = 16;
%let _OUTPUT1_col18_type = $;
%let _OUTPUT1_col18_format = $16.;
%let _OUTPUT1_col18_informat = $16.;
%let _OUTPUT1_col18_label = %nrquote(last data item in my table);
%let _OUTPUT1_col18_input0 = last_item;
%let _OUTPUT1_col18_exp = ;
%let _OUTPUT1_col18_input = last_item;
%let _OUTPUT1_col18_input_count = 1;
%let _OUTPUT1_filetype = WorkTable;
答案 0 :(得分:-1)
在SAS DI Studio中,用户编写的节点可以具有多个可见的输出表&amp;可以从节点图标访问,通过右键单击表,您可以看到更改表详细信息(表名,类型,长度,格式,信息,等等)。请注意我使用的是4.6版本
在我的屏幕截图中,我的用户编写节点已经有三个输出表。添加第四个: 右键单击节点 选择&#34;添加工作表&#34; 将打开一个新窗口,供您输入表格详细信息
在节点的DI Auto生成代码中,sas会将_OUTPUT1,2,3,4分配给您的表格,因此在您的代码中,您可以使用相应的&amp;输出
来引用它们。