38%macro mm_createdataset(libds=,tableuri=,outds=work.mm_createdataset,mDebug=0);
39%local dbg errorcheck tempds1 tempds2 tempds3;
40%
if &mDebug=0 %then %let dbg=*;
43%
if %index(&libds,.)>0 %then %
do;
45 data;run;%let tempds1=&syslast;
46 %mm_getlibs(outds=&tempds1)
49 if upcase(libraryref)=
"%upcase(%scan(&libds,1,.))";
50 call symputx(
'liburi',LibraryId,
'l');
53 data;run;%let tempds2=&syslast;
54 %mm_gettables(uri=&liburi,outds=&tempds2)
57 where upcase(tablename)=
"%upcase(%scan(&libds,2,.))";
58 &dbg putlog tableuri=;
59 call symputx(
'tableuri',tableuri);
65%mm_getcols(tableuri=&tableuri,outds=&tempds3)
67%
if %mf_nobs(&tempds3)=0 %then %
do;
68 %put &libds (&tableuri) has no columns defined!!;
75 set &tempds3 end=last;
76 if _n_=1 then call execute(
'data &outds;');
79 if SAScolumntype=
'C' then type=
'$';
80 attrib=
'attrib '!!cats(colname)!!
' length='!!cats(type,SASColumnLength,
'.');
82 if not missing(sasformat) then fmt=
' format='!!cats(sasformat);
83 if not missing(sasinformat) then infmt=
' informat='!!cats(sasinformat);
84 if not missing(coldesc) then desc=
' label='!!quote(cats(coldesc));
86 attrib=trim(attrib)!!fmt!!infmt!!desc!!
';';
89 if last then call execute(
'call missing(of _all_);stop;run;');
92%mend mm_createdataset;