推 bbearh:感謝! 應可以用. Key word "select into". 我消化一下 09/29 08:17
假設妳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