ポインタを1ステップ戻す必要があります。あなたはマイナス1ステップで前進することを求めてこれを行います。これを使用してください:
'{"名前": "'名前(+) - 1 '"、';
私は知っていますが、動作します。ここで
はsashelp.classと例です。
コード:
data _null_;
set sashelp.class end = eof;
if _N_ eq 1 then
put '[';
put '{ "Name":"' Name+(-1)
'","Sex":"' Sex+(-1)
'","Age":"' Age+(-1)
'","Height":"' Height+(-1)
'","Weight":"' Weight+(-1)
'"}';
if eof then
put ']';
else put ',';
run;
結果:
[
{ "Name":"Alfred","Sex":"M","Age":"14","Height":"69","Weight":"112.5"}
,
{ "Name":"Alice","Sex":"F","Age":"13","Height":"56.5","Weight":"84"}
,
{ "Name":"Barbara","Sex":"F","Age":"13","Height":"65.3","Weight":"98"}
,
{ "Name":"Carol","Sex":"F","Age":"14","Height":"62.8","Weight":"102.5"}
,
{ "Name":"Henry","Sex":"M","Age":"14","Height":"63.5","Weight":"102.5"}
,
{ "Name":"James","Sex":"M","Age":"12","Height":"57.3","Weight":"83"}
,
{ "Name":"Jane","Sex":"F","Age":"12","Height":"59.8","Weight":"84.5"}
,
{ "Name":"Janet","Sex":"F","Age":"15","Height":"62.5","Weight":"112.5"}
,
{ "Name":"Jeffrey","Sex":"M","Age":"13","Height":"62.5","Weight":"84"}
,
{ "Name":"John","Sex":"M","Age":"12","Height":"59","Weight":"99.5"}
,
{ "Name":"Joyce","Sex":"F","Age":"11","Height":"51.3","Weight":"50.5"}
,
{ "Name":"Judy","Sex":"F","Age":"14","Height":"64.3","Weight":"90"}
,
{ "Name":"Louise","Sex":"F","Age":"12","Height":"56.3","Weight":"77"}
,
{ "Name":"Mary","Sex":"F","Age":"15","Height":"66.5","Weight":"112"}
,
{ "Name":"Philip","Sex":"M","Age":"16","Height":"72","Weight":"150"}
,
{ "Name":"Robert","Sex":"M","Age":"12","Height":"64.8","Weight":"128"}
,
{ "Name":"Ronald","Sex":"M","Age":"15","Height":"67","Weight":"133"}
,
{ "Name":"Thomas","Sex":"M","Age":"11","Height":"57.5","Weight":"85"}
,
{ "Name":"William","Sex":"M","Age":"15","Height":"66.5","Weight":"112"}
]
よろしく、 Vasilij
が、これは、変数のホワイトスペースとは何の関係もありませんが、それはプット機能のプロパティです@andrey_sz代わりトリム –
のストリップ機能を使用するようにしてください。変数の後には常に1つの空白が入ります。 (+) - 1を使用すると、1つのスペースだけ後ろに移動する必要があります。以下の私のasnwerを見てください。 –