Macros for SAS Application Developers
https://github.com/sasjs/core
mp_ds2inserts.sas File Reference

Export a dataset to SQL insert statements. More...

Go to the source code of this file.

Detailed Description

Converts dataset values to SQL insert statements for use across multiple database types.

Usage:

%mp_ds2inserts(sashelp.class,outref=myref,outds=class)
data class;
  set sashelp.class;
  stop;
proc sql;
%inc myref;
Parameters
[in]dsThe dataset to be exported
[in]maxobs=(max) The max number of inserts to create
[out]outref=(0) The output fileref. If it does not exist, it is created. If it does exist, new records are APPENDED.
[out]schema=(0) The library (or schema) in which the target table is located. If not provided, is ignored.
[out]outds=(0) The output table to load. If not provided, will default to the table in the &ds parameter.
[in]flavour=(SAS) The SQL flavour to be applied to the output. Valid options:
  • SAS (default) - suitable for regular proc sql
  • PGSQL - Used for Postgres databases
[in]applydttm=(YES) If YES, any columns using datetime formats will be converted to native DB datetime literals

SAS Macros

Version
9.2
Author
Allan Bowe (credit mjsq)

Definition in file mp_ds2inserts.sas.