Re: [問題] sas整理資料的問題
補充一下
原po的欄位名稱可能不是照順序(應該是不可能)
如果你要你的欄位清單
proc sql;
create table cols as
select name
from sashelp.vcolumn
where libname = 'a' and
memname = 'a01';
quit;
接下來就靠用歐巴桑一個一個選出欄位接下面的程式囉
※ 引述《west1996 (焦了六年變脆了)》之銘言:
: %macro selection;
: data
: %do i=2 %to 30;
: a.a0&i
: %end;
: ;
: set a.a01;
: %do i=2 %to 30;
: if var&i^=0 then output a.a0&i;
: %end;
: run;
: %mend selection;
:
: %selection
:
: ---
:
: %macro selection;
: %do i=2 %to 30;
: data a.a0&i;
: set a.a01;
: if var&i=0 then delete;
: run;
: %end;
: %mend selection;
:
: %selection
:
: ※ 引述《hanjing (心寬念純)》之銘言:
: : data a.a02;
: : set a.a01
: : if var2=0 then delete;
: : run;
: : data a.a03;
: : set a.a01
: : if var3=0 then delete;
: : run;
: : 有沒有指令可以重覆這些動作對a01這個檔
: : 刪除不同變數中為0的值,然後另外存成a02和a03這個檔
: : 也就是說a02只有刪除var2為0的值,但此時var3仍會有為0的值
: : 而
: : a03只會刪除var3為0的值,但此表格中的var2仍會有為0的值
: : 由於變數達30個左右
: : 所以想問有沒有指令可以代替這些重覆的動作
: : 感謝
:
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.167.176.207
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 3 之 4 篇):