diff --git a/all.sas b/all.sas index d18573d..531a9ab 100644 --- a/all.sas +++ b/all.sas @@ -2216,6 +2216,14 @@ Usage: select count(*) into: orig from &lib..&ds; quit; + %local notfound; + proc sql outobs=10 noprint; + select distinct &col into: notfound separated by ' ' + from &lib..&ds + where &col not in ( + select &ccol from &clib..&cds + ); + %mp_abort(iftrue= (&syscc ne 0) ,mac=&sysmacroname ,msg=%str(syscc=&syscc after macro query) @@ -2226,7 +2234,7 @@ Usage: test_description=symget('desc'); test_result='FAIL'; test_comments="&sysmacroname: &lib..&ds..&col has &result values " - !!"not in &clib..&cds..&ccol "; + !!"not in &clib..&cds..&ccol.. First 10 vals:"!!symget('notfound'); %if &test=ANYVAL %then %do; if &result < &orig then test_result='PASS'; %end; @@ -4230,6 +4238,72 @@ filename &fref1 clear; %mend mp_filtervalidate; /** + @file + @brief Creates a dataset with column metadata. + @details This macro takes the `proc contents` output and "tidies it up" in the + following ways: + + @li Blank labels are filled in with column names + @li Formats are reconstructed with default values + @li Types such as DATE / TIME / DATETIME are inferred from the formats + + Example usage: + + %mp_getcols(sashelp.airline,outds=work.myds) + + @param ds The dataset from which to obtain column metadata + @param outds= (work.cols) The output dataset to create. Sample data: + |NAME $|LENGTH 8|VARNUM 8|LABEL $|FORMAT $49|TYPE $1 |DDTYPE $| + |---|---|---|---|---|---|---| + |AIR|8|2|international airline travel (thousands)|8.|N|NUMERIC| + |DATE|8|1|DATE|MONYY.|N|DATE| + |REGION|3|3|REGION|$3.|C|CHARACTER| + +