maxvarlen_macro: Check the Length of all character variables length is LT 200
MAXVARLEN Macro:
According to FDA released the Guidance for Industry: Providing Regulatory
Submission in Electronic Format – NDAs which was released in Jan 1999, one of the important point to comply with the agency’s regulations is : The length of any character values cannot be more than 200 characters.
Submission in Electronic Format – NDAs which was released in Jan 1999, one of the important point to comply with the agency’s regulations is : The length of any character values cannot be more than 200 characters.
Here is the macro which will give us the list of character variables whose actual length (not the assigned) is greater than 200. You can use this program to check the maximum length of all variables of any dataset at once. This macro will create a table with list of variables and their length.
***********************************************************************;
*** Program: macro_maxvarlen.sas ***;
*** Version: 1.0 ***;
*** Client: ***;
*** Protocol: ***;
*** Programmer: sarath Annapareddy ***;
*** Date: 22APR2009 ***;
*** Purpose: Macro used to check the list of variables whose ***;
*** length is GT 200. ***;
*** ***;
******************************************************************* ***;libname prodn 'H:\Company\Client\Testing\XXXX\XXXXX\Test map datasets';
option nofmterr;
***********************************************************************;
*** Program: macro_maxvarlen.sas ***;
*** Version: 1.0 ***;
*** Client: ***;
*** Protocol: ***;
*** Programmer: sarath Annapareddy ***;
*** Date: 22APR2009 ***;
*** Purpose: Macro used to check the list of variables whose ***;
*** length is GT 200. ***;
*** ***;
******************************************************************* ***;libname prodn 'H:\Company\Client\Testing\XXXX\XXXXX\Test map datasets';
option nofmterr;
%macro maxvarlen(base,dsn);data dsn;
set sashelp.vcolumn(where=(libname=upcase("&base") and memname=upcase("&dsn") and type='char'));
call symput(cats("var",_n_),name);
id=_n_;
keep name id;
run;
*Counting number of character variables in the dataset;
proc sql noprint;
select count(*)into :nvars from dsn;
quit;
*Computing max. length of each character variable in the dataset;
%do i = 1 %to &nvars;
proc sql noprint;
create table maxlen&i as
select max(length(&&var&i)) as mlen from &base..&dsn
quit;
%end;
*Concatenating all the datasets;
data final;
id=_n_;
set %do i= 1 %to &nvars;
maxlen&i
%end;
;
run;
%mend;
%maxvarlen(prodn,ae);
*Final dataset with list of variables whose length is GT 200;proc sql;
create table mxvarlen as
select a.name ,b.mlen
from dsn as a, final as b
where a.id=b.id and mlen gt 200;
quit;
Comments
Post a Comment