Skip to content

Commit

Permalink
fix: supporting long character strings in mp_stripdiffs.sas
Browse files Browse the repository at this point in the history
  • Loading branch information
^ committed Apr 30, 2024
1 parent 96e8b09 commit ed20bca
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
17 changes: 11 additions & 6 deletions all.sas
Original file line number Diff line number Diff line change
Expand Up @@ -13544,7 +13544,8 @@ create table &outds as select "No " as _____DELETE__THIS__RECORD_____,
/* create SAS code to apply to stage_ds */
data _null_;
set &ds1;
file &fref1;
file &fref1 lrecl=33000;
length charval $32767;
if _n_=1 then put 'proc sql noprint;';
by descending processed_dttm key_hash is_pk;
if move_type='M' then do;
Expand All @@ -13553,15 +13554,17 @@ data _null_;
end;
if IS_PK=0 then do;
put " " tgtvar_nm '=' @@;
charval=quote(cats(oldval_char));
cnt=count(oldval_char,'"');
charval=quote(trim(substr(oldval_char,1,32765-cnt)));
if tgtvar_type='C' then put charval @@;
else put oldval_num @@;
if not last.is_pk then put ',';
end;
else do;
if first.is_pk then put " where 1=1 " @@;
put " and " tgtvar_nm '=' @@;
charval=quote(cats(oldval_char));
cnt=count(oldval_char,'"');
charval=quote(trim(substr(oldval_char,1,32765-cnt)));
if tgtvar_type='C' then put charval @@;
else put oldval_num @@;
end;
Expand All @@ -13573,7 +13576,8 @@ data _null_;
/* gating if - as only need PK now */
if is_pk=1;
put ' AND ' tgtvar_nm '=' @@;
charval=quote(cats(newval_char));
cnt=count(newval_char,'"');
charval=quote(trim(substr(newval_char,1,32765-cnt)));
if tgtvar_type='C' then put charval @@;
else put newval_num @@;
end;
Expand All @@ -13582,15 +13586,16 @@ data _null_;
put "insert into &outds set _____DELETE__THIS__RECORD_____='No' " @@;
end;
put " ," tgtvar_nm '=' @@;
charval=quote(cats(oldval_char));
cnt=count(oldval_char,'"');
charval=quote(trim(substr(oldval_char,1,32765-cnt)));
if tgtvar_type='C' then put charval @@;
else put oldval_num @@;
end;
if last.key_hash then put ';';
run;

/* apply the modification statements */
%inc &fref1/source2;
%inc &fref1/source2 lrecl=33000;

%if &mdebug=0 %then %do;
proc sql;
Expand Down
17 changes: 11 additions & 6 deletions base/mp_stripdiffs.sas
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ create table &outds as select "No " as _____DELETE__THIS__RECORD_____,
/* create SAS code to apply to stage_ds */
data _null_;
set &ds1;
file &fref1;
file &fref1 lrecl=33000;
length charval $32767;
if _n_=1 then put 'proc sql noprint;';
by descending processed_dttm key_hash is_pk;
if move_type='M' then do;
Expand All @@ -168,15 +169,17 @@ data _null_;
end;
if IS_PK=0 then do;
put " " tgtvar_nm '=' @@;
charval=quote(cats(oldval_char));
cnt=count(oldval_char,'"');
charval=quote(trim(substr(oldval_char,1,32765-cnt)));
if tgtvar_type='C' then put charval @@;
else put oldval_num @@;
if not last.is_pk then put ',';
end;
else do;
if first.is_pk then put " where 1=1 " @@;
put " and " tgtvar_nm '=' @@;
charval=quote(cats(oldval_char));
cnt=count(oldval_char,'"');
charval=quote(trim(substr(oldval_char,1,32765-cnt)));
if tgtvar_type='C' then put charval @@;
else put oldval_num @@;
end;
Expand All @@ -188,7 +191,8 @@ data _null_;
/* gating if - as only need PK now */
if is_pk=1;
put ' AND ' tgtvar_nm '=' @@;
charval=quote(cats(newval_char));
cnt=count(newval_char,'"');
charval=quote(trim(substr(newval_char,1,32765-cnt)));
if tgtvar_type='C' then put charval @@;
else put newval_num @@;
end;
Expand All @@ -197,15 +201,16 @@ data _null_;
put "insert into &outds set _____DELETE__THIS__RECORD_____='No' " @@;
end;
put " ," tgtvar_nm '=' @@;
charval=quote(cats(oldval_char));
cnt=count(oldval_char,'"');
charval=quote(trim(substr(oldval_char,1,32765-cnt)));
if tgtvar_type='C' then put charval @@;
else put oldval_num @@;
end;
if last.key_hash then put ';';
run;

/* apply the modification statements */
%inc &fref1/source2;
%inc &fref1/source2 lrecl=33000;

%if &mdebug=0 %then %do;
proc sql;
Expand Down

0 comments on commit ed20bca

Please sign in to comment.