症例フロー図の作成

475 Views

March 31, 24

スライド概要

[第3回大阪sas勉強会]山野辺浩己

profile-image

SAS言語を中心として,解析業務担当者・プログラマなのコミュニティを活性化したいです

シェア

またはPlayer版

埋め込む »CMSなどでJSが使えない場合

関連スライド

各ページのテキスト
1.

症例フロー図の作成 山野辺 浩己

2.

フロー図の作成 • フロー図の作成は,毎回結構頭を悩まされます • 最近,方々の手段を用いて作成しています • それらの紹介を致します • エクセルDDE • Proc stream • Proc odstable • Sgplot(polygon statement)

3.

Excel DDE • エクセルで事前に雛形を作成し, • そこにDDEでゴリゴリ書き出す方法 • 利点 • 使い慣れたエクセルを使えるため手間がいらない • デメリット • 他の帳票がrtfな中,エクセルで作成する点

4.

• さしておもしろくない方法なのでコードと見本は省略します

5.

Proc stream • 雛形を事前に作成して,それをproc streamで流します • 利点 • コードが短く,単純な構造で済ませられること • デメリット • 事前の雛形が必要になること

6.

• 雛形

7.

%let m1 =21; %let m2 =54; %let m3 =25; %let m4 =21; ... %let m16=21; %let time=2018-06-22; filename in "F:\DS\SA1\部内専用\SA1\7G_work\個人用\山野辺\大阪勉強会\03\test_in.rtf" lrecl = 32755; filename out "F:\DS\SA1\部内専用\SA1\7G_work\個人用\山野辺\大阪勉強会\03\test_out.rtf" lrecl = 32755; proc stream outfile=out resetdelim="rdlm" quoting=single; begin rdlm; %include in; ;;;;

8.

• 実行後

9.

• Rtf上にマクロを埋め込むことで,擬似的な集計も可能 • phamaSUGの論文を一部紹介

11.

Macro cx • %macro cx(flag); • %global rx; • %let u1=%sysfunc(dosubl( • 'proc sql noprint; • select sum(&flag.) • into :rx TRIMMED • from adsl; • quit;')); • &rx. • %mend cx; Cx内では,dosubl関数を使っています. 1.SQLを呼び出しています. 2.引数のカウントを取って,マクロ変数rxへ 3.マクロ変数rxを展開して,返り値としています dosubl(呼出し文); SASが読み込んだ瞬間に,呼出し文にあたる部分 のコードが,実行されます.

12.

Macro cx • %macro cx(flag); • %global rx; • %let u1=%sysfunc(dosubl( • 'proc sql noprint; • select sum(&flag.) • into :rx TRIMMED • from adsl; • quit;')); • &rx. • %mend cx; Cx内では,dosubl関数を使っています. 1.SQLを呼び出しています. 2.引数のカウントを取って,マクロ変数rxへ 3.マクロ変数rxを展開して,返り値としています

13.

Macro cx • %macro cx(flag); • %global rx; • %let u1=%sysfunc(dosubl( • 'proc sql noprint; • select sum(&flag.) • into :rx TRIMMED • from adsl; • quit;')); • &rx. • %mend cx; Cx内では,dosubl関数を使っています. 1.SQLを呼び出しています. 2.引数のカウントを取って,マクロ変数rxへ 3.マクロ変数rxを展開して,返り値としています

14.

Macro cx • %macro cx(flag); • %global rx; • %let u1=%sysfunc(dosubl( • 'proc sql noprint; • select sum(&flag.) • into :rx TRIMMED • from adsl; • quit;')); • &rx. • %mend cx; Cx内では,dosubl関数を使っています. 1.SQLを呼び出しています. 2.引数のカウントを取って,マクロ変数rxへ 3.マクロ変数rxを展開して,返り値としています

15.

Macro cx • %macro cx(flag); • %global rx; • %let u1=%sysfunc(dosubl( • 'proc sql noprint; • select sum(&flag.) • into :rx TRIMMED • from adsl; • quit;')); • &rx. • %mend cx; Flagに与えた変数をカウントして, 結果を返してくれるマクロ! Cx内では,dosubl関数を使っています. 1.SQLを呼び出しています. 2.引数のカウントを取って,マクロ変数rxへ 3.マクロ変数rxを展開して,返り値としています

18.

Proc odstable • テーブルを書いて,擬似的にフロー図に見せかける • 利点 • テンプレートを用意せずに済む. • 出力する内容に左右されない • デメリット • テーブルで図を描くというもどかしさ • Programが書きづらく読み難い

20.

←データセットの1行目 ←データセットの2行目 ←データセットの3行目 ←データセットの4行目

21.

proc odstable data=test_data; ** 罫線処理; style={frame=void}; ** column; column out1 - out5; ** 罫線処理; cellstyle _row_=1 and _col_ in (1) as {borderbottomwidth=1 borderleftwidth=1 bordertopwidth=1 } ,_row_=1 and _col_ in (2) as {borderbottomwidth=1 borderrightwidth=1 bordertopwidth=1 } ,_row_=2 and _col_ in (1) as { borderrightwidth=1 } ,_row_=2 and _col_ in (2,3,4) as {borderbottomwidth=1 } ,_row_=3 and _col_ in (1,4) as {borderbottomwidth=1 borderrightwidth=1 } ,_row_=3 and _col_ in (2,5) as {borderbottomwidth=1 } ,_row_=4 and _col_ in (1,4) as {borderbottomwidth=1 borderleftwidth=1 bordertopwidth=1 } ,_row_=4 and _col_ in (2,5) as {borderbottomwidth=1 borderrightwidth=1 bordertopwidth=1 } ; ** header; define header header1; start=out1; end=out1; end; define header header2; start=out2; end=out2; end; define header header3; start=out3; end=out3; end; define header header4; start=out4; end=out4; end; define header header5; start=out5; end=out5; end; ** column; define out1; print_headers=off; just=left; style={cellwidth=200}; end; define out2; print_headers=off; just=right; style={cellwidth=100}; end; define out3; print_headers=off; just=left; style={cellwidth=100}; end; define out4; print_headers=off; just=left; style={cellwidth=200}; end; define out5; print_headers=off; just=right; style={cellwidth=100}; end; run;

22.

Sgplot(polygon statement) • Polygonで自由線を引き,フロー図を作成する • 利点 • Figureをsgplotで画像データとして作成できる • テンプレートが不要で,rtfに出力できる • • • • デメリット 画像のため,数字の切り貼りが出来ない 編集や扱いに難有り Programが書きづらく読み難い

23.

Proc sgplot • Polygon statement ・指定した座標から座標へ,線を描く ・(イメージ)一筆書きで,連続した線を描く →座標を指定したデータセットを作成しなければならない・・・ ということで・・・

25.

• • /*枠線の座標*/ do boxid="1"; • x = 0 ; y = 100; output; • x = 33 ; output; • y = 87 ; output; • x=0;output; • • call missing(boxid); end; • /*区切り線の座標*/ • do boxid='1-1'; • x = 0 ; y = 96.5 ; output; • x = 33 ; y = 96.5 ; output; • call missing(boxid); • end; • /*テキスト部分*/ • do textid='1'; • text = "登録例" • text = "&n1_0. 例" ; x = 22 ; y = 98 ; output; • text = "AAAA群" • text = " &n1_1. 例" ; x = 22 ; y = 95 ; output; • text = "BBBB群" • text = " &n1_2. 例" ; x = 22 ; y = 92 ; output; • text = "CCCC群" ; x = 5 ; y = 89 ; output; • text = " &n1_3. 例" ; x = 22 ; y = 89 ; output; • call missing(of text textid); • end; ; x = 1 ; y = 98 ; output; ; x = 5 ; y = 95 ; output; ; x = 5 ; y = 92 ; output; ←1つのブロックを書くための情報 これをブロックの分,書いてやる 今回は7個分書くため,左のコード×7

26.

• proc sgplot data=samp1 pad=(top=10% left=10%) noborder noautolegend; • /*箱の線を引いている部分*/ • polygon id=boxid x=x y=y/lineattrs=(thickness=2); • /*テキスト描画部分 • --セル内改行したい場合は、データセットの値に#をいれる。 • • */ text x=x y=y text=text / textattrs=(size=8 family="MS PGothic" ) position=right splitchar='#' ; • /*つなぎ線部分*/ • series x=line_x y=line_y/ group=lineid lineattrs=(color=black pattern=1 thickness=2) ; • /*軸設定*/ • xaxis display=none min=0 max=100 offsetmin=0 offsetmax=0; • yaxis display=none min=0 max=100 offsetmin=0 offsetmax=0; • run;

27.

参考 • データステップ100万回 http://sas-tumesas.blogspot.com/2016/11/blog-post_15.html ・コード提供 森岡さん • Joseph Hinson,2018 https://www.pharmasug.org/proceedings/2017/BB/Pharma SUG-2017-BB02.pdf