Skip to main content

文字列の長さに合わせてブロックコメントを生成する

  • length()およびklength()を組み合わせ、マルチバイト文字を含めたいい感じの文字長を計算し、ブロックコメントを生成する。
    • 実行環境によってはうまくいかないこともある。
data _null_;
    comment_text = strip(&comment_contents.);
    comment_len = (length(comment_text) - klength(comment_text)) / 2 + klength(comment_text);
    comment_line = '/*-' || repeat('-', comment_len - 1) || '-*/';
    put comment_line;
    put '/* ' "&comment_contents." ' */';
    put comment_line;
run;