From 15687be5d6bb98151b690d1ff2fcf3267f598796 Mon Sep 17 00:00:00 2001 From: Allan Bowe Date: Fri, 30 Oct 2020 11:43:15 +0100 Subject: [PATCH] fix: tidy up of SAS flavour DDL --- all.sas | 10 ++++++---- base/mp_getddl.sas | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/all.sas b/all.sas index 5b05641..2fa2d7f 100644 --- a/all.sas +++ b/all.sas @@ -2642,7 +2642,7 @@ run; %let curds=%scan(&dsnlist,&x); data _null_; file &fref mod; - length nm lab $1024; + length nm lab $1024 typ $20; set &colinfo (where=(upcase(memname)="&curds")) end=last; if _n_=1 then do; @@ -2656,10 +2656,12 @@ run; end; else put " ,"@@; if length(format)>1 then fmt=" format="!!cats(format); - len=" length="!!cats(length); - lab=" label="!!quote(trim(label)); + if length(label)>1 then lab=" label="!!quote(trim(label)); if notnull='yes' then notnul=' not null'; - put name type len fmt notnul lab; + if type='char' then typ=cats('char(',length,')'); + else if length ne 8 then typ='num length='!!left(length); + else typ='num'; + put name typ fmt notnul lab; run; /* Extra step for data constraints */ diff --git a/base/mp_getddl.sas b/base/mp_getddl.sas index 076ea78..f308714 100644 --- a/base/mp_getddl.sas +++ b/base/mp_getddl.sas @@ -131,7 +131,7 @@ run; %let curds=%scan(&dsnlist,&x); data _null_; file &fref mod; - length nm lab $1024; + length nm lab $1024 typ $20; set &colinfo (where=(upcase(memname)="&curds")) end=last; if _n_=1 then do; @@ -145,10 +145,12 @@ run; end; else put " ,"@@; if length(format)>1 then fmt=" format="!!cats(format); - len=" length="!!cats(length); - lab=" label="!!quote(trim(label)); + if length(label)>1 then lab=" label="!!quote(trim(label)); if notnull='yes' then notnul=' not null'; - put name type len fmt notnul lab; + if type='char' then typ=cats('char(',length,')'); + else if length ne 8 then typ='num length='!!left(length); + else typ='num'; + put name typ fmt notnul lab; run; /* Extra step for data constraints */