37%macro mm_createdataset(libds=,tableuri=,outds=work.mm_createdataset,mDebug=0);
38%local dbg errorcheck tempds1 tempds2 tempds3;
39%
if &mDebug=0 %then %let dbg=*;
42%
if %index(&libds,.)>0 %then %
do;
44 data;run;%let tempds1=&syslast;
45 %mm_getlibs(outds=&tempds1)
48 if upcase(libraryref)=
"%upcase(%scan(&libds,1,.))";
49 call symputx(
'liburi',LibraryId,
'l');
52 data;run;%let tempds2=&syslast;
53 %mm_gettables(uri=&liburi,outds=&tempds2)
56 where upcase(tablename)=
"%upcase(%scan(&libds,2,.))";
57 &dbg putlog tableuri=;
58 call symputx(
'tableuri',tableuri);
64%mm_getcols(tableuri=&tableuri,outds=&tempds3)
66%
if %mf_nobs(&tempds3)=0 %then %
do;
67 %put &libds (&tableuri) has no columns defined!!;
74 set &tempds3 end=last;
75 if _n_=1 then call execute(
'data &outds;');
78 if SAScolumntype=
'C' then type=
'$';
79 attrib=
'attrib '!!cats(colname)!!
' length='!!cats(type,SASColumnLength,
'.');
81 if not missing(sasformat) then fmt=
' format='!!cats(sasformat);
82 if not missing(sasinformat) then infmt=
' informat='!!cats(sasinformat);
83 if not missing(coldesc) then desc=
' label='!!quote(cats(coldesc));
85 attrib=trim(attrib)!!fmt!!infmt!!desc!!
';';
88 if last then call execute(
'call missing(of _all_);stop;run;');
91%mend mm_createdataset;