Re: [程式] SAS 如何用資料檔內的資料當MARCO 的in …

看板Statistics作者 (朝右邊鋒邁進)時間14年前 (2011/09/29 02:08), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串2/2 (看更多)
假設妳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
感謝! 應可以用. Key word "select into". 我消化一下
09/29 08:17, 1F
文章代碼(AID): #1EWsANtP (Statistics)
文章代碼(AID): #1EWsANtP (Statistics)