Hi Experts, We are trying to remove the special pattern from start and end of the strings if present. In the following code options mprint;
libname odmds 'D:\skp\odmds';
%let NON_PRINTABLE_ENCLOSING_CHAR=#**;
%let splln=%length(&NON_PRINTABLE_ENCLOSING_CHAR);
%put &=splln.;
data odmds.test;
infile cards dlm=",";
input ItemData_Value:$100.;
cards;
#** both leading and laging spaces #**
#** only leading spaces#**
#**only laging spaces #**
;
run;
%macro spl_test;
data odmds.test1;
set odmds.test;
if substr(strip(ItemData_Value),1,&splln) = "&NON_PRINTABLE_ENCLOSING_CHAR."
= substr(strip(ItemData_Value),length(strip(ItemData_Value))-&splln.+1,&splln.) then do;
ItemData_Value1 = substr(ItemData_Value,&splln+1,length(ItemData_Value)-2*&splln);
ItemData_Value2 = tranwrd(ItemData_Value,"&NON_PRINTABLE_ENCLOSING_CHAR",'');
*ItemData_Value3 = prxchange('s/^#\*\*|#\*\*$,/', -1, ItemData_Value);
end;
run;
%mend spl_test;
%spl_test; Issue: 1. ItemData_Value1, ItemData_Value2 are not retaining the trailing spaces how ever the leading spaces are retained. 2. Also if we can get any help on ItemData_Value3 praxchange regex to replace the special character to null. Thank you in advance. Note: Kindly use BASE SAS Editor or SAS EG to see the final dataset result.
... View more