Re: [程式] SAS 如何用資料檔內的資料當MARCO 的in …
假設妳id都沒有重複
/*測試資料集*/
data temp;
input id;
cards;
1
3
5
7
1000
;
run;
/*用sql抓共有多少筆id*/
proc sql noprint;
select count(*) into :count
from temp;
quit;
/*利用%left指令,將所有id分別命名為id1,id2,...,到最後一筆*/
proc sql noprint;
select id into :id1-:id%left(&count)
from temp;
quit;
/*測試*/
%macro test(input);
data test;
test=&input;
run;
proc print data=test;
run;
%mend;
%test(&id4);
/*輸出結果*/
test=7
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 60.250.86.244
推
09/29 08:17, , 1F
09/29 08:17, 1F
討論串 (同標題文章)
完整討論串 (本文為第 2 之 2 篇):