データの分割

 【問題】1つのデータセットを2つに分割
/*testデータ*/
data test ;
    no=1 ; flg=. ; output ;
    no=2 ; flg=1 ; output ;
    no=3 ; flg=. ; output ;
run ;
test
no fig
1 .
2 1
3 .








/*(1)flg^=1の場合はaに出力、flg=1の場合はbに出力する*/ 
  data a b ;
    set test ;
    if     flg^=1 then output a ;
    else if flg=1 then output b ;
  run ;
 
dataA
no fig
1 .
3 .
dataB
no fig
2 1







/*(2)全てのOBSをaに出力、flg=1の場合はbに出力する*/
 
  data a b ;
    set test ;
    output a ;
    if flg=1 then output b ;
  run ;
 
dataA
no fig
1 .
2 1
3 .
dataB
no fig
2 1










最終更新:2008年10月13日 12:50
ツールボックス

下から選んでください:

新しいページを作成する
ヘルプ / FAQ もご覧ください。