As an exercise, I am trying to disassemble a sting into individual characters, then reassemble the characters back to the original string into a new SAS dataset.
I can successfully disassemble the sting with this code:
data looky (drop=string); input string $ 1-50; do i=1 to length(string); letter = substr(string, i, 1); output; end; cards; The quick brown fox jumped over the lazy dogs ; run;
However, when I attempt to reassemble the string, the blanks are removed. I've tried using TRIM, STRIP, CAT, CATT and CATS and they all remove blanks:
data what; length string $ 50; retain string; set work.looky; string=strip(string)||letter; run;
STRIP (and the other functions) returns Thequickbrownfoxjumpedoverthelazydogs
This simple put statement write the complete string to the log, blanks included:
data _null_; set work.looky; put @i letter @@; run;
The quick brown fox jumped over the lazy dogs
I am obviously misapplying the TRIM, STRIP CATT functions, but I am truly baffled as to what to use that will retain blanks. Simply using string||letter returns a completely blank column. What am I doing wrong?
... View more