More Related Content More from Visual Cognition and Modeling Lab More from Visual Cognition and Modeling Lab (20) 110929實習3. PROCPRINT data test; input a1-a5; cards; 12345 228910 ; proc print data=test; run; 將資料列印出來至output。 6. VAR data test; input a1-a5; cards; 12345 228910 ; proc print data=test; var a1 a2 a3; run; VAR指的是限定列印出來的變項。 7. VAR data test; input a1-a5; cards; 12345 228910 ; proc print data=test; var a1 a2 a3; run; OUTPUT 8. ID data test; input a1-a5; cards; 12345 228910 ; proc print data=test; ID a1; run; 因為使用print程序會多加一欄OBS,跟你說這筆資料在整個資料集中的哪裡。如果你當初coding時就有將編號coding進去,你可以使用這個指令來告訴SAS你的編號在哪裡 9. ID data test; input a1-a5; cards; 12345 228910 ; proc print data=test; ID a1; run; OUTPUT 11. data test; input a1-a5; cards; 1 1 3 4 5 2 1 8 9 10 3 2 5 6 4 4 2 6 9 4 ; proc print data=test; by a2; run; BY BY 可將列印的結果依你指定的變項分組,結果可見下頁;但BY一定要先將你所指定的變項按照小到大來排序,不然就會有error。 排序! 12. data test; input a1-a5; cards; 1 1 3 4 5 2 1 8 9 10 3 2 5 6 4 4 2 6 9 4; proc print data=test; by a2; run; BY 13. data test; input a1-a5; cards; 1 2 3 4 5 2 2 8 9 10 3 1 5 6 4 4 1 6 9 4 ; proc print data=test; by a2; run; BY 排序! 14. data test; input a1-a5; cards; 1 2 3 4 5 2 2 8 9 10 3 1 5 6 4 4 1 6 9 4 ; proc print data=test; by a2; run; BY LOG 411 proc print data=test; 412 by a2; 413 run; ERROR: Data set WORK.TEST is not sorted in ascending sequence. The current BY group has a2 = 2 and the next BY group has a2 = 1. 資料集WORK.SET沒有以升冪的方式排列。先有a2=2的BY group再來是a2=1 排序! 15. data test; input a1-a5; cards; 1 1 3 4 5 2 2 8 9 10 3 1 5 6 4 4 1 6 9 4 ; proc print data=test; by a2; run; BY 17. data test; input a1-a5; cards; 1 1 3 4 5 2 2 8 9 10 3 1 5 6 4 4 1 6 9 4 ; proc means; run; PROC MEANS 進行一些基本描述性統計的計算。 20. data test; input a1-a5; cards; 1 1 3 4 5 2 2 8 9 10 3 1 5 6 4 4 1 6 9 4 ; proc means skew kurt; Title ‘Skewness and Kurtosis’; run; Proc means後加你想要知道的統計值,中間用空格隔開。 Title是一個小指令,可將輸出的表格加上你想要的標題。 21. data test; input a1-a5; cards; 1 1 3 4 5 2 2 8 9 10 3 1 5 6 4 4 1 6 9 4 ; proc means skew kurt; Title ‘Skewness and Kurtosis’; run; 23. OUTPUT data test; input a1-a5; cards; 1 1 3 4 5 2 1 8 9 10 3 2 5 6 4 4 2 6 9 4 ; proc means; output out=a mean=m1-m5; proc print; run; OUTPUT的指令會要求proc means所計算出來的統計數值存在一個輸出檔內;下一行的proc print就可列印出來這個輸出檔的結果。 24. OUTPUT data test; input a1-a5; cards; 1 1 3 4 5 2 1 8 9 10 3 2 5 6 4 4 2 6 9 4 ; proc means; output out=a mean=m1-m5; proc print; run; 當我說要計算mean時,SAS會計算我之前輸入變項的平均值(此例就是a1-a5) ,而等號後面接的是我將這五個平均值的命名。