If you want to delete leading and trailing spaces('20'x) and "enters" (LF, CR) you could try to "resolve" it his way
data test;
x='0A20200D55722055720D0A6F6C6F67790D0A20200D0A0D0A0D0A0D0A'x;
put "*" x= char. +(-1)'*';
put "*" x= hex. +(-1)'*';
s=FINDC(x,, 1,'KS'); /* first "non space" */
e=FINDC(x,,-vlength(x),'KS'); /* last "non space" */
put s= e=;
x=substr(x,s,e-s);
put "*" x= char. +(-1)'*';
put "*" x= hex. +(-1)'*';
run;
Bart
@yabwon I want to delete CR, LF and Spaces or any special characters before and after the string. Then how to tweak your code?
Define "special characters" ?
The answer will probably be: change FINDC() functions modifiers.
Basically "SK" means "search for first character that is NOT a space, a horizontal tab, a vertical tab, a carriage return, a line feed, and a form feed".
Probably you would like to add "C" for control characters, so in total "SCK".
Or maybe just make it: "ANP" to search for first alphabetic character, punctuation mark, or digits, an underscore, and English letter?
Bart
P.S. are you using two accounts: @David_Billa and @Babloo ?
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.