[問題] SAS巨集

看板Statistics作者 (carrot)時間16年前 (2009/07/22 23:00), 編輯推噓1(1010)
留言11則, 4人參與, 7年前最新討論串1/1
請教一下版上的高手 感謝 我寫了一個巨集 但是 跑出來不是我要的(我是SAS新手)>"< 不曉得是哪裡錯了=.= % macro age(a); % macro icd(b); data test.rate_&a; set test.rate_&b; by sex year agesub; retain count count_total; if first.agesub then do; count=1; count_total=count; end; else do; count=count+1; count_total=count_total+count; end; if last.agesub; % mend icd; % icd(140); % icd(150); % icd(151); % mend age; % age(1401); % age(1501); % age(1511); run; 我想要上面巨集跑出來的結果 跟下面分開寫跑出來的結果 一樣 但是 不曉得我巨集哪裡寫錯了 跑不出我要的結果 data test.rate_1401; set test.rate_140; by sex year agesub; retain count count_total; if first.agesub then do; count=1; count_total=count; end; else do; count=count+1; count_total=count_total+count; end; if last.agesub; run; ------------------------------------------- data test.rate_1501; set test.rate_150; by sex year agesub; retain count count_total; if first.agesub then do; count=1; count_total=count; end; else do; count=count+1; count_total=count_total+count; end; if last.agesub; run; -------------------------------------------- data test.rate_1511; set test.rate_151; by sex year agesub; retain count count_total; if first.agesub then do; count=1; count_total=count; end; else do; count=count+1; count_total=count_total+count; end; if last.agesub; run; -- ◢█◢▊◢◣◢◣◢▉ ◢◣◢◣◢◣ ▊▊▉ ▊▉█ ▊▉▊▉ ◥◣◥▉▉ █◤ ◥◣◥◣ 擁抱讓距離更接近 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.231.152.142 ※ 編輯: carrotree 來自: 61.231.152.142 (07/22 23:01)

07/22 23:06, , 1F
印象marco age ice 不能連包
07/22 23:06, 1F

07/22 23:07, , 2F
寫的話可能改 macro age(a,b) 這樣吧
07/22 23:07, 2F

07/22 23:36, , 3F
不過最好把log 貼出來 大概知道哪裡有問題
07/22 23:36, 3F

07/22 23:36, , 4F
妳語法中if first.agesub then do; 沒指定 條件
07/22 23:36, 4F

07/22 23:38, , 5F
if last.agesub; 也沒寫條件 你知道 by 的用途嗎?
07/22 23:38, 5F

07/22 23:39, , 6F
by sex year agesub; 這個用途知道嗎
07/22 23:39, 6F

07/23 00:05, , 7F
試試看把ice拿到外面來定義 age裡面直接呼叫ice可不可行
07/23 00:05, 7F

07/24 00:00, , 8F
請問if first.agesub then do; 沒指定條件的意思是指?
07/24 00:00, 8F

07/24 09:28, , 9F
last.agesub 會產生內定預設值 0 或 1
07/24 09:28, 9F

07/24 22:53, , 10F
請問指定條件的意思是說像 if x>3 then 大於3就是指定條見?
07/24 22:53, 10F

01/02 14:57, 7年前 , 11F
印象marco age https://muxiv.com
01/02 14:57, 11F
文章代碼(AID): #1APocBip (Statistics)