




已閱讀5頁,還剩20頁未讀, 繼續(xù)免費閱讀
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
SAS軟件應(yīng)用,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ù)塊結(jié)束,必須單獨占一行 run; 數(shù)據(jù)步結(jié)束語句(可以省略) 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ù)文件格式的導(dǎo)入和導(dǎo)出 導(dǎo)入數(shù)據(jù) import過程 proc import out=a3 datafile=e:tmp.xls dbms=excel replace; run; 導(dǎo)出數(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)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 二年級下冊數(shù)學(xué)教案 - 第三單元 第一節(jié)【第一課時】 數(shù)一數(shù)(一)(認識并感受“千”1)北師大版
- 2025年師范大學(xué)協(xié)議管理辦法
- 勞動協(xié)議:勞務(wù)分包協(xié)議(2025年版)
- 2024年水利機械項目資金需求報告代可行性研究報告
- 2024年高性能陶瓷刀具材料項目資金需求報告代可行性研究報告
- 全國清華版信息技術(shù)小學(xué)三年級上冊新授課 第11課 智能輸詞句-詞組和整句輸入 教學(xué)設(shè)計
- 2025年度手房交易資金監(jiān)管補充協(xié)議
- 2025年度大米產(chǎn)業(yè)投資基金簡易合作協(xié)議
- 2025年度商標同授權(quán)及品牌授權(quán)許可合同
- 二零二五年度網(wǎng)紅直播帶貨營銷推廣服務(wù)合同
- 學(xué)校食堂食品安全主體責(zé)任風(fēng)險管控清單(日管控)
- 肛瘺患者的護理查房
- 2023-2024學(xué)年河北省涿州市實驗中學(xué)中考數(shù)學(xué)模試卷含解析
- 國防動員教案
- 湖北省武漢市江岸區(qū)2024年七年級下學(xué)期期末數(shù)學(xué)試題附答案
- 2024-2034年中國藏香豬養(yǎng)殖行業(yè)市場深度分析及發(fā)展?jié)摿︻A(yù)測報告
- 罪犯個性分測驗
- 辦公室職業(yè)健康業(yè)務(wù)培訓(xùn)
- 五年級英語閱讀理解(共20篇)
- 2024年重慶三峰環(huán)境集團招聘筆試參考題庫附帶答案詳解
- (2024年)傳染病培訓(xùn)課件
評論
0/150
提交評論