The macro expects an existing table name as a parameter (&base_dataset). It creates a temporary table 'local_temp' from the metadata.
1 Code Block
MACRO
Explanation : Definition of the macro that extracts metadata, sorts it by variable order, and writes the SAS format definition code to the log. Note: it calls a utility macro '%delete_dataset' which is not defined in this script.
Copied!
%macro get_append_base(base_dataset);
proc contents noprint data= &base_dataset. out= local_temp; run;
proc sort data= local_temp; by varnum; run;
data _null_;
set local_temp end= last;
by varnum;
obs = _N_;
;
if obs = 1 then do;
put "***************************************************************************************;";
put;
put " data stuff;";
put " set _null_;";
put " format";
end;
formatted = compress(name) || ' ' || compress(cat(format,FORMATL,"."));
put " " formatted;
if last then do;
put " ;";
put " run;";
put;
put "***************************************************************************************;";
end;
run;
%delete_dataset(work,local_temp);
%mend get_append_base;
put "***************************************************************************************;";
27
END;
28
RUN;
29
%delete_dataset(work,local_temp);
30
%mend get_append_base;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.