SAS Programming Professionals,
Did you know
that you can easily create a report showing which variables in a SAS data set
are missing labels?
You can do
this by accessing the COLUMNS table in the SAS Dictionary tables. Here is an example:
libname ProdData "G:\Data
Delivery\ImportantData";
%macro varlmss(LIBname,DSName);
title "Variables with
Missing Labels in Data Set &DSName.";
proc sql;
select
name label="Variable Name"
from
dictionary.columns
where
libname = "&LIBNAME"
and
memname = upcase("&DSName")
and
memtype = "DATA"
and
label=" ";
quit;
%mend;
%VARLMSS(ProdData,
Delivery01);
The
example begins with a LIBNAME statement which identifies the SAS data library of
our target data set: Delivery01. That is the data set we want to check for
missing variable labels.
Next,
we have the VARLMSS macro which accepts two parameters:
- LIBname – the libname of the SAS data library that holds the target data set
- DSName – the name of the target data set
The
macro uses PROC SQL to access the COLUMNS dictionary table which holds
information about every variable in every SAS data set allocated to our
program. We subset the COLUMNS table by
reading only rows that match the LIBNAME, MEMNAME (target data set name), and
have missing values for LABEL. (Don’t
worry about memtype = "DATA"; that is just to ensure that we only access information
about SAS data sets; not views or other objects). The result is a nice report of all of the
variables in Delivery01 that do not have labels.
This
is a great QC check to use for SAS data sets you intend to deliver to a client!
No comments:
Post a Comment