OK. It is a little bit complicated.
data have;
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";
run;
data temp;
set have;
n+1;
do i=1 to countw(sample,':');
temp=scan(sample,i,':');
output;
end;
drop i sample;
run;
data temp;
set temp;
by n;
if not last.n then do;
call scan(temp,-1,p,l,'_','ka');
name=cats('"',substr(temp,p),'"');
value=cats('"',substr(temp,1,p-1),'",') ;
end;
else do;name=' ';value=cats('"',temp,'"');end;
drop p l;
run;
data want;
merge temp temp(keep=n value rename=(n=_n value=_value) firstobs=2);
if n=_n;
keep n name _value;
run;
filename x 'c:\temp\x.json';
data _null_;
set want;
by n;
file x lrecl=32767;
if first.n then put '{';
put name $ +(-1) ':' _value $;
if last.n then put '}';
run;
... View more