data _null_;
length sample $32767. Phrase Key Value $32767.;
sample ="The following are the graphical (non-control) characters defined by
ISO 8859-1 (1987). DESCRIPTION : in words aren't all that helpful,
but they're the best we can do in text. A graphics file illustrating
the character set should be available from the same archive as this
file.RESULT :success. INTERPRETATION : ISO 8859-1 (1987).CREATED_BY:Questy.CREATED_ON:29/07/1963";
/*
Assumptions:
One did not know what keys would be except the fact that they precede a colon.
periods are the separators between differnt sections.
*/
put '{';
count_periods=countc(sample,'.');
do count=1 to count_periods+1;
Phrase = scan(sample,count,'.');
if indexc(Phrase,':') > 0 then do;
Key=strip(scan(Phrase,1,':'));
Value = strip(scan(Phrase,2,':'));
put '"'key+(-1)'":"'Value+(-1)'"';
end;
end;
put '}';
run;
I modified the input by putting a period after success
... View more