看板 Statistics 關於我們 聯絡資訊
[軟體程式類別]: SAS [程式問題]: 資料處理 [軟體熟悉度]: 新手 [問題敘述]: 我設立一個巨集 其中&amount是1~13連續的 %do j = 1 %to &amount; data slope1_5; set slope&j; run; %end; 但是其中有兩個資料集不存在 於是點開 slope1_5 就會跳出 data set has 0 observations. 如果我改用 %do j = 1 %to &amount; %if %sysfunc (exist(slope&j)) %then %do; data slope1_5; set slope&j; run; %end; %end; 那slope1_5只會出現最後一筆資料 proc print 出來 顯示每一筆資料都會跑一次 應該是後面那筆資料覆蓋了前一筆的資料 有沒有什麼方法能夠set 這種連續檔名 但中間有不存在資料集的方法? -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 60.250.75.217 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Statistics/M.1635302331.A.90D.html
AeiCheng: set 那行改成 10/27 11:29
AeiCheng: set %do i = 1 %to &amount. ; slope&i. 10/27 11:29
AeiCheng: %end;; 10/27 11:29
AeiCheng: 試試 感謝 不過測試了之後 log 出現error:data does not exist slope1_5 一樣 no observations 10/27 11:29 ※ 編輯: zxcccc (60.250.75.217 臺灣), 10/27/2021 11:59:58
west1996: 照你的第二個寫法,把"data slope1_5;set"這幾個字搬到 10/27 13:26
west1996: %do之前,把";run;"放到%end;之後,整個%do迴圈跟%if判 10/27 13:26
west1996: 斷式只要包“slope&j"這七個字母就好 10/27 13:26
ba9bully10: https://i.imgur.com/nY5TsCq.png 10/27 13:36
感謝 有成功了 ※ 編輯: zxcccc (60.250.75.217 臺灣), 10/27/2021 13:50:33