




已閱讀5頁,還剩20頁未讀, 繼續(xù)免費閱讀
版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
SAS軟件應用,Sas數(shù)據(jù)分析過程,建立數(shù)據(jù)集 整理數(shù)據(jù)集 分析數(shù)據(jù)、按照適當?shù)男问捷敵?一、sas數(shù)據(jù)集與數(shù)據(jù)文件,1、數(shù)據(jù)集的建立 數(shù)據(jù)步 data a1; 數(shù)據(jù)步開始 input x y; 輸入的變量 cards; 數(shù)據(jù)塊開始(也可用infile 1 2 指定數(shù)據(jù)文件存儲位置) 3 4 ; 數(shù)據(jù)塊結束,必須單獨占一行 run; 數(shù)據(jù)步結束語句(可以省略) Infile e:tmp.dat;,過程步生成數(shù)據(jù)集(很多sas過程都可以) proc means data=sashelp.class noprint; var weight; output out=a2; run; 也可以采用sas的ods生成數(shù)據(jù)集。,2、sas與其他數(shù)據(jù)文件格式的導入和導出 導入數(shù)據(jù) import過程 proc import out=a3 datafile=e:tmp.xls dbms=excel replace; run; 導出數(shù)據(jù)export過程 proc export data=sashelp.class outfile=e:stu.csv dbms=csv replace; run;,二、數(shù)據(jù)集整理(數(shù)據(jù)加工),1、變量類型和缺失值 數(shù)值型 缺失值用 ” . ” 表示 字符型 缺失值用 ”空格“ 表示 日期型 自定義型 根據(jù)自定義的類型屬于字符還是數(shù)值,data a4; infile e:stu.csv delimiter = , dsd firstobs=2; input name:$20. sex:$6. age height weight; bmi=(weight/2)/(height/100); 數(shù)據(jù)加工語句 run;,data a5; set sashelp.clss; bmi=(weight/2)/(height/100);數(shù)據(jù)加工語句 run;,2、數(shù)據(jù)集選項,data a6; set sashelp.class(keep=weight); run; 以上程序的作用是生成的數(shù)據(jù)集中僅包含sashelp.class中得weight變量,常用的選項有keep drop rename where等,3、對觀測的選擇 If語句 If 表達式 then 語句; else 語句;,data a6; set sashelp.class(keep=weight); if weight100 then w=低體重; else w=高體重; run; 邏輯表達式為1時執(zhí)行then后邊的語句,否則不執(zhí)行后邊的語句。 上例weight100為時執(zhí)行 w=低體重 其他的執(zhí)行 w=高體重,4、常用的運算符,data a6; set sashelp.class; if (sex=男) then w=低體重; else w=高體重; run;,data a6; set sashelp.class; if sex=男 and age14 then m=1; run;,5、where 表達式 data a7; set sashelp.class(where=(sex=男); run; proc print data=a7; run;,6、按變量值對數(shù)據(jù)集排序,proc sort data=sashelp.class out=a7; by age; by descending weight; run;,7、用sas語句生成新變量 a 賦值語句 b 使用sas函數(shù) Total=sum(weight,height),data a4; infile e:stu.csv delimiter = , dsd firstobs=2; input name:$20. sex:$6. age height weight; bmi=(weight/2)/(height/100);(賦值語句) run;,c 求和語句 data a8 ; set sashelp.class; i+1; run;,8、do end語句,data a8 ; set sashelp.class; if sex=男 then do ; a=1; b=1; end; run;,9、sas函數(shù),常用的函數(shù),data a4; infile e:stu.csv delimiter = , dsd firstobs=2; input name:$20. sex:$6. age height weight; bmi=(weight/2)/(height/100); bmi2=round(bmi,0.01) ; run;,data a9; name = tomas; name2 = upcase(name); run; proc print data=a9; run;,data a9; x = good bad middle high; x1 = scan(x,1, ); x2 = scan(x,2); x3 = scan(x,3); x4 = scan(x,4); run;,data a9; x1 = good; x2 = bad; x3 = middle; x4 = x1 | | x2 | | x3; run; proc print data=a9; run;,10、循環(huán)語句,data a10 ; do a=1 to 20 ; x = a*10; output; end; run;,data a10 ; do a=1 to 20 by 2; x = a*10; output; end; run;,data a10 ; do a=1 to 20 by 2 unt
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 水利實務試題及答案
- 白庇中醫(yī)護理方案
- 喉罩的護理措施
- IT培訓咨詢師年中分享
- 2025年 東營市中醫(yī)院招聘考試試卷附答案
- 2025年中國噴霧曬黑機行業(yè)市場全景分析及前景機遇研判報告
- 銷售員工衛(wèi)生培訓
- 信息技術培訓小結
- 教師安全培訓會
- 現(xiàn)代心血管病護理
- 老人集中供養(yǎng)管理制度
- 音標考試卷及答案二年級
- 四川省成都市武侯區(qū)2023-2024學年八年級下學期語文期末試卷(含答案)
- 幼小銜接合同協(xié)議書
- 2025年福建省糧食行業(yè)職業(yè)技能競賽(糧油質量檢驗員)備賽試題庫(含答案)
- 2025上半年水發(fā)集團社會招聘(391人)筆試參考題庫附帶答案詳解
- 2025蕪湖市鳩江區(qū)裕溪口街道社區(qū)工作者考試真題
- 2025年廣東省深圳市龍華區(qū)中考數(shù)學二模試卷
- 熊膽粉初稿完整版本
- 堅守廉潔底線弘揚清風正氣
- 小區(qū)物業(yè)管理計劃書:范文
評論
0/150
提交評論