Skip to content

Commit ed20bca

Browse files
author
^
committed
fix: supporting long character strings in mp_stripdiffs.sas
1 parent 96e8b09 commit ed20bca

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

all.sas

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13544,7 +13544,8 @@ create table &outds as select "No " as _____DELETE__THIS__RECORD_____,
1354413544
/* create SAS code to apply to stage_ds */
1354513545
data _null_;
1354613546
set &ds1;
13547-
file &fref1;
13547+
file &fref1 lrecl=33000;
13548+
length charval $32767;
1354813549
if _n_=1 then put 'proc sql noprint;';
1354913550
by descending processed_dttm key_hash is_pk;
1355013551
if move_type='M' then do;
@@ -13553,15 +13554,17 @@ data _null_;
1355313554
end;
1355413555
if IS_PK=0 then do;
1355513556
put " " tgtvar_nm '=' @@;
13556-
charval=quote(cats(oldval_char));
13557+
cnt=count(oldval_char,'"');
13558+
charval=quote(trim(substr(oldval_char,1,32765-cnt)));
1355713559
if tgtvar_type='C' then put charval @@;
1355813560
else put oldval_num @@;
1355913561
if not last.is_pk then put ',';
1356013562
end;
1356113563
else do;
1356213564
if first.is_pk then put " where 1=1 " @@;
1356313565
put " and " tgtvar_nm '=' @@;
13564-
charval=quote(cats(oldval_char));
13566+
cnt=count(oldval_char,'"');
13567+
charval=quote(trim(substr(oldval_char,1,32765-cnt)));
1356513568
if tgtvar_type='C' then put charval @@;
1356613569
else put oldval_num @@;
1356713570
end;
@@ -13573,7 +13576,8 @@ data _null_;
1357313576
/* gating if - as only need PK now */
1357413577
if is_pk=1;
1357513578
put ' AND ' tgtvar_nm '=' @@;
13576-
charval=quote(cats(newval_char));
13579+
cnt=count(newval_char,'"');
13580+
charval=quote(trim(substr(newval_char,1,32765-cnt)));
1357713581
if tgtvar_type='C' then put charval @@;
1357813582
else put newval_num @@;
1357913583
end;
@@ -13582,15 +13586,16 @@ data _null_;
1358213586
put "insert into &outds set _____DELETE__THIS__RECORD_____='No' " @@;
1358313587
end;
1358413588
put " ," tgtvar_nm '=' @@;
13585-
charval=quote(cats(oldval_char));
13589+
cnt=count(oldval_char,'"');
13590+
charval=quote(trim(substr(oldval_char,1,32765-cnt)));
1358613591
if tgtvar_type='C' then put charval @@;
1358713592
else put oldval_num @@;
1358813593
end;
1358913594
if last.key_hash then put ';';
1359013595
run;
1359113596

1359213597
/* apply the modification statements */
13593-
%inc &fref1/source2;
13598+
%inc &fref1/source2 lrecl=33000;
1359413599

1359513600
%if &mdebug=0 %then %do;
1359613601
proc sql;

base/mp_stripdiffs.sas

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ create table &outds as select "No " as _____DELETE__THIS__RECORD_____,
159159
/* create SAS code to apply to stage_ds */
160160
data _null_;
161161
set &ds1;
162-
file &fref1;
162+
file &fref1 lrecl=33000;
163+
length charval $32767;
163164
if _n_=1 then put 'proc sql noprint;';
164165
by descending processed_dttm key_hash is_pk;
165166
if move_type='M' then do;
@@ -168,15 +169,17 @@ data _null_;
168169
end;
169170
if IS_PK=0 then do;
170171
put " " tgtvar_nm '=' @@;
171-
charval=quote(cats(oldval_char));
172+
cnt=count(oldval_char,'"');
173+
charval=quote(trim(substr(oldval_char,1,32765-cnt)));
172174
if tgtvar_type='C' then put charval @@;
173175
else put oldval_num @@;
174176
if not last.is_pk then put ',';
175177
end;
176178
else do;
177179
if first.is_pk then put " where 1=1 " @@;
178180
put " and " tgtvar_nm '=' @@;
179-
charval=quote(cats(oldval_char));
181+
cnt=count(oldval_char,'"');
182+
charval=quote(trim(substr(oldval_char,1,32765-cnt)));
180183
if tgtvar_type='C' then put charval @@;
181184
else put oldval_num @@;
182185
end;
@@ -188,7 +191,8 @@ data _null_;
188191
/* gating if - as only need PK now */
189192
if is_pk=1;
190193
put ' AND ' tgtvar_nm '=' @@;
191-
charval=quote(cats(newval_char));
194+
cnt=count(newval_char,'"');
195+
charval=quote(trim(substr(newval_char,1,32765-cnt)));
192196
if tgtvar_type='C' then put charval @@;
193197
else put newval_num @@;
194198
end;
@@ -197,15 +201,16 @@ data _null_;
197201
put "insert into &outds set _____DELETE__THIS__RECORD_____='No' " @@;
198202
end;
199203
put " ," tgtvar_nm '=' @@;
200-
charval=quote(cats(oldval_char));
204+
cnt=count(oldval_char,'"');
205+
charval=quote(trim(substr(oldval_char,1,32765-cnt)));
201206
if tgtvar_type='C' then put charval @@;
202207
else put oldval_num @@;
203208
end;
204209
if last.key_hash then put ';';
205210
run;
206211

207212
/* apply the modification statements */
208-
%inc &fref1/source2;
213+
%inc &fref1/source2 lrecl=33000;
209214

210215
%if &mdebug=0 %then %do;
211216
proc sql;

0 commit comments

Comments
 (0)