在SAS中,如何创建/更改Postgres表?

时间:2017-02-09 02:04:49

标签: postgresql sas

我有SAS代码,如果已经创建但仍然为空,将写入postgres表。如果不存在或已有数据,如何从SAS(或使用引入SAS宏变量的脚本)创建/更改postgres表?字段数可能会改变。目前,我使用filename选项和管道来写入postgres文件。

filename pgout pipe %unquote(%bquote(')/data/dwight/IFS6.2/app/PLANO/sas_to_psql.sh
                             %bquote(")&f_out_schema.%bquote(").&file_name.
                             %bquote(')
                             )
;

我尝试过使用此版本,但它不起作用:

filename pgout pipe %unquote(%bquote(')/data/dwight/IFS6.2/app/PLANO/sas_to_psql.sh
                            %bquote('')CREATE TABLE mdo_backend.fob_id_desc 
                                       SELECT * FROM &library_name..&file_name.
                            %bquote(")&f_out_schema.%bquote(").&file_name./('')/
                            %bquote(')
                            )
;

这是我使用的脚本:

LOAD_TO_PSQL.SH


#!/bin/bash

. /data/projects/ifs/psql/config.sh 

psql -d $DB -tAq -c "COPY $1 FROM STDIN USING DELIMITERS '|'"

0 个答案:

没有答案
相关问题