看板 Statistics 關於我們 聯絡資訊
※ 引述《startend (Pride & Prejudice)》之銘言: : 因為最近開始使用SAS,順便考SAS BASE : 不過太久沒碰的下場就是好多東西都忘記了.... : 想請問以下幾個題目,希望強者能夠提供一些見解(跪) : 1. : data work.test; : capacity = 150; : if 100 le capacity le 200 then airplanetype = 'large' and staff = 10; /*if 100 ge capacity le 200 .....比較像*/ : else airplanetype = 'small' and staff = 5; : run; : 題目希望data set 長成如下,上面這個是錯的,只是我不確定錯在哪裡 : capacity airplanetype staff : 150 large 10 : 就題目而言,是因為else 少了一個if嗎? : 另外就是if-then的語法裡面,如果有假設三個if-then的時候 : 一般都是打成if-then : else if-then : else (最後這個就不用加上?) : 2.submit following : libname sasdata ' ' : data allobs; : set sasdata.banks; : capital = 0; : do year = 2000 to 2020 by 5; : capital+((capital+2000)*rate); : output; /*sasdata.bank的每一筆都會做五次這個動作,所以allobs就有25筆*/ : end; : run; : if sasdata.banks has five observation,how many observations will the ALLOBS : contain? Ans:25 : 這個我就掉到五里霧裡面了.... : 另外一個疑問是,output的使用時機,雖然講義上面是寫prevent continuous looping, : 但感覺有一點抽象,另外是不是用了output,後面一定要用stop; ? : 3.submit following : data work.XXX : set work.people (in = inemp) : work.money (in = insal); : if insal = inemp; /*work.XXX是由work.people跟work.money垂直疊起來*/ /*in=inemp表示若此筆是由work.people來的話 inemp就會是1否則為0, insal同理 */ /*因此每一筆不是從 work.people 就是從 work.money來的*/ /*即 每一筆的 inemp 與 insal 不是 1跟0 就是 0跟1 不會有 insal=inemp*/ : run; : work.people has 5 observations, and work.money has 7 observations : How many obs contain in work.XXXX? Ans: 0 : 因為這應該是一個concatenating,為什麼不是12個 obs? : 4. : 在從外部抓資料的時候 : input style $ @; : style是一個variable的名字,但後面的@代表什麼意義? : 因為我看到的都是input @4 style $2.;類似這種的,但@在後面的有特別意義嗎? /*sorry 目前沒有SAS可用, 請查help 印象中好像是不用換行直接讀資料*/ : 5. : data work.total; : infile where end = eof; : input name $ salary; : total + salary; : (if statement) : run; /*個人覺得where是個檔案名,陷阱*/ /*end=eof 表示用eof這個欄位來存取這一筆是否為最後一筆(eof=1),也可取別的名稱*/ /*if eof=1;是 if eof=1 then output;的縮寫,也可寫成 if eof;*/ : which statement would write the last observation to the output data set? : Ans: if eof = 1; : 不太了解題意,最後想問一下if如果再沒有then的搭配下,跟where statement有什麼 : 差別呢? : 我想對大家來說這些都是很簡單的問題,還請大家不賜吝教,感恩 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.229.226.47
x1234567:第一題我答錯了..該改成 then do; ... end; 07/28 12:49
x1234567:原本有人有回正確的...現在不見了 07/28 12:50