当我使用PROC EXPORT时,如何为列分配值?

时间:2013-02-14 03:50:20

标签: sas

%if %sysfunc(exist(working.__extra_nos__)) %then %do;
    proc export data=working.__extra_nos__
        dbms=oracle replace;
        password="&password.";
        tablename="sch.no_selection_&env_type.";
        url="&dburl.";
        username="&user.";
    run;

sch.no_selection_& env_type也有一个名为identifier的列,它不在__extra_nos__中,因此我想在导出它时将其设置为& identifier。

我该怎么做?

2 个答案:

答案 0 :(得分:1)

通过LIBNAME而不是PROC EXPORT访问数据库DBMS要容易得多。 http://support.sas.com/documentation/cdl/en/acreldb/63647/HTML/default/viewer.htm#a003113591.htm

libname mydblib oracle user=testuser password=testpass path=hrdept_002;

[调整你的oracle安装细节]

然后,您只需使用普通语言(SQL或数据步骤)创建或修改表格,而不是导出...

proc sql;
create table mydblib.sch.no_selection_&env_type. as
  select *, "&identifier" as identifier from work.tempextras;
quit;

data mydblib.sch.no_selection_&env_type.;
set work.tempextras;
identifier="&identifier";
run;

答案 1 :(得分:0)

__extra_nos__创建数据集,然后输入标识符。然后导出该数据集。

 
data work.tempextras;
    set working.__extra_nos__;
    identifier = &identifier.;
run;


%if %sysfunc(exist(working.__extra_nos__)) %then %do;
    proc export data=work.tempextras;
        dbms=oracle replace;
        password="&password.";
        tablename="sch.no_selection_&env_type.";
        url="&dburl.";
        username="&user.";
    run;

proc datasets library = work; /*delete the temp dataset*/
    delete tempextras; 
run;