39%macro mm_createdataset(libds=,tableuri=,outds=work.mm_createdataset,mDebug=0);
40%local dbg errorcheck tempds1 tempds2 tempds3;
41%
if &mDebug=0 %then %let dbg=*;
44%
if %index(&libds,.)>0 %then %
do;
46 data;run;%let tempds1=&syslast;
47 %mm_getlibs(outds=&tempds1)
50 if upcase(libraryref)=
"%upcase(%scan(&libds,1,.))";
51 call symputx(
'liburi',LibraryId,
'l');
54 data;run;%let tempds2=&syslast;
55 %mm_gettables(uri=&liburi,outds=&tempds2)
58 where upcase(tablename)=
"%upcase(%scan(&libds,2,.))";
59 &dbg putlog tableuri=;
60 call symputx(
'tableuri',tableuri);
66%mm_getcols(tableuri=&tableuri,outds=&tempds3)
68%
if %mf_nobs(&tempds3)=0 %then %
do;
69 %put &libds (&tableuri) has no columns defined!!;
76 set &tempds3 end=last;
77 if _n_=1 then call execute(
'data &outds;');
80 if SAScolumntype=
'C' then type=
'$';
81 attrib=
'attrib '!!cats(colname)!!
' length='!!cats(type,SASColumnLength,
'.');
83 if not missing(sasformat) then fmt=
' format='!!cats(sasformat);
84 if not missing(sasinformat) then infmt=
' informat='!!cats(sasinformat);
85 if not missing(coldesc) then desc=
' label='!!quote(cats(coldesc));
87 attrib=trim(attrib)!!fmt!!infmt!!desc!!
';';
90 if last then call execute(
'call missing(of _all_);stop;run;');
93%mend mm_createdataset;