Production Ready Macros for SAS Application Developers
https://github.com/sasjs/core
mp_lib2inserts.test.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Testing mp_ds2inserts.sas macro
4
5 <h4> SAS Macros </h4>
6 @li mf_mkdir.sas
7 @li mp_getddl.sas
8 @li mp_lib2inserts.sas
9 @li mp_assert.sas
10
11**/
12
13/* grab 20 datasets from SASHELP */
14%let path=%sysfunc(pathname(work));
15%mf_mkdir(&path)
16libname sashlp "&path";
17proc sql noprint;
18create table members as
19 select distinct lowcase(memname) as memname
20 from dictionary.tables
21 where upcase(libname)="SASHELP"
22 and memtype='DATA'; /* exclude views */
23data _null_;
24 set work.members;
25 call execute(cats('data sashlp.',memname,';set sashelp.',memname,';run;'));
26 if _n_>20 then stop;
27run;
28
29/* export DDL and inserts */
30%mp_getddl(sashlp, schema=work, fref=tempref)
31%mp_lib2inserts(sashlp, schema=work, outref=tempref,maxobs=50)
32
33/* check if it actually runs */
34options source2;
35%inc tempref;
36
37/* without errors.. */
38%mp_assert(
39 iftrue=(&syscc=0),
40 desc=Able to export 20 tables from sashelp using mp_lib2inserts,
41 outds=work.test_results
42)