版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、數(shù)據(jù)清理技術(shù)數(shù)據(jù)清理技術(shù)中國(guó)疾控中心衛(wèi)生統(tǒng)計(jì)室中國(guó)疾控中心衛(wèi)生統(tǒng)計(jì)室數(shù)據(jù)清洗數(shù)據(jù)清洗p從數(shù)據(jù)收集結(jié)束,到統(tǒng)計(jì)分析之前,需要對(duì)數(shù)據(jù)從數(shù)據(jù)收集結(jié)束,到統(tǒng)計(jì)分析之前,需要對(duì)數(shù)據(jù)做的清理工作做的清理工作數(shù)據(jù)清洗數(shù)據(jù)清洗p數(shù)據(jù)雙錄入對(duì)比數(shù)據(jù)雙錄入對(duì)比p數(shù)據(jù)合并數(shù)據(jù)合并p查找重復(fù)值查找重復(fù)值p查找缺失值查找缺失值p查找異常值查找異常值雙錄入對(duì)比雙錄入對(duì)比pExcelExcel用到的函數(shù):用到的函數(shù):pIfIf函數(shù)函數(shù)pIf(If(判斷條件判斷條件, ,條件滿(mǎn)足返回值條件滿(mǎn)足返回值, ,條件不滿(mǎn)足返回值條件不滿(mǎn)足返回值) )pexactexact函數(shù)函數(shù)比較兩個(gè)文本是否相同比較兩個(gè)文本是否相同pexact(
2、exact(比較文本比較文本1,1,比較文本比較文本2)2)poffsetoffset函數(shù)函數(shù)返回給定偏移量的新區(qū)域返回給定偏移量的新區(qū)域poffset(offset(參照區(qū)域參照區(qū)域, ,行行, ,列列) )雙錄入對(duì)比雙錄入對(duì)比psmall(small(數(shù)據(jù)區(qū)域數(shù)據(jù)區(qū)域, ,第幾小第幾小 ) ) 計(jì)算單元格范圍的第幾小的數(shù)值計(jì)算單元格范圍的第幾小的數(shù)值pColumn()Column()p返回單元格所在號(hào)返回單元格所在號(hào)pRow()Row()p返回單元格所在行號(hào)返回單元格所在行號(hào)雙錄入對(duì)比雙錄入對(duì)比pSASSAS命令命令:pproc compare base=proc compare ; ;p
3、by by 變量變量1 1 變量變量2 2 ; ;prun;run;雙錄入對(duì)比雙錄入對(duì)比pproc compareproc compare語(yǔ)句調(diào)用數(shù)據(jù)比較過(guò)程,選項(xiàng)語(yǔ)句調(diào)用數(shù)據(jù)比較過(guò)程,選項(xiàng)basebase和和comparecompare分別指定兩個(gè)比較和被比較的數(shù)據(jù)集;分別指定兩個(gè)比較和被比較的數(shù)據(jù)集;nosummarynosummary的作用是不顯示一些概括性的結(jié)果。的作用是不顯示一些概括性的結(jié)果。pbyby語(yǔ)句指定的變量有點(diǎn)類(lèi)似于索引的作用,通常語(yǔ)句指定的變量有點(diǎn)類(lèi)似于索引的作用,通常指定指定idid號(hào)。如果兩個(gè)數(shù)據(jù)集的觀(guān)測(cè)數(shù)不同,利用號(hào)。如果兩個(gè)數(shù)據(jù)集的觀(guān)測(cè)數(shù)不同,利用byby語(yǔ)句可以
4、保證它們比較的仍然是同一個(gè)語(yǔ)句可以保證它們比較的仍然是同一個(gè)idid號(hào),號(hào),而不會(huì)出現(xiàn)錯(cuò)位比較的情況。而不會(huì)出現(xiàn)錯(cuò)位比較的情況。雙錄入對(duì)比雙錄入對(duì)比pdata a1;data a1;pinput id g gender age marriage height weight nation;input id g gender age marriage height weight nation;pcards;cards;p(數(shù)據(jù))(數(shù)據(jù))p; ;pdata a2;data a2;pinput id g gender age marriage height weight nation;input id
5、 g gender age marriage height weight nation;pcards;cards;p(數(shù)據(jù))(數(shù)據(jù))p; ;pproc compare base=a1 compare=a2 nosummary;proc compare base=a1 compare=a2 nosummary;prun;run;雙錄入對(duì)比雙錄入對(duì)比雙錄入對(duì)比雙錄入對(duì)比查找缺失值查找缺失值pExcelExcel函數(shù):函數(shù):pIfIf函數(shù)函數(shù)pIf(If(判斷條件判斷條件, ,條件滿(mǎn)足返回值條件滿(mǎn)足返回值, ,條件不滿(mǎn)足返回值條件不滿(mǎn)足返回值) )pexactexact函數(shù)函數(shù)比較兩個(gè)文本是否相同比
6、較兩個(gè)文本是否相同pexact(exact(比較文本比較文本1,1,比較文本比較文本2)2)poffsetoffset函數(shù)函數(shù)返回給定偏移量的新區(qū)域返回給定偏移量的新區(qū)域poffset(offset(參照區(qū)域參照區(qū)域, ,行行, ,列列) )查找缺失值查找缺失值psmall(small(數(shù)據(jù)區(qū)域數(shù)據(jù)區(qū)域, ,第幾小第幾小 ) ) 計(jì)算單元格范圍的第幾小的數(shù)值計(jì)算單元格范圍的第幾小的數(shù)值pColumn()Column()p返回單元格所在號(hào)返回單元格所在號(hào)pRow()Row()p返回單元格所在行號(hào)返回單元格所在行號(hào)查找缺失值查找缺失值pSASSAS可用可用missingmissing函數(shù)實(shí)現(xiàn)函數(shù)實(shí)
7、現(xiàn)p如果結(jié)合數(shù)組和自動(dòng)變量,可以一次性實(shí)現(xiàn)所有如果結(jié)合數(shù)組和自動(dòng)變量,可以一次性實(shí)現(xiàn)所有變量缺失值的輸出變量缺失值的輸出查找缺失值查找缺失值pdata a1;data a1;pinput id g gender age marriage height weight nation;input id g gender age marriage height weight nation;pmiss_g=missing(g);miss_g=missing(g);pmiss_gender=missing(gender);miss_gender=missing(gender);pmiss_age=miss
8、ing(age);miss_age=missing(age);pmiss_marriage=missing(marriage);miss_marriage=missing(marriage);pmiss_height=missing(height);miss_height=missing(height);pmiss_weight=missing(weight);miss_weight=missing(weight);pmiss_nation=missing(nation);miss_nation=missing(nation);pcards;cards;p(數(shù)據(jù))(數(shù)據(jù))p;pproc pri
9、nt;proc print;prun;run;查找缺失值查找缺失值p部分結(jié)果部分結(jié)果查找缺失值查找缺失值p利用數(shù)組和自動(dòng)變量利用數(shù)組和自動(dòng)變量pdata missing;data missing;pset a;set a;parray chaarray cha* * _character_ ; _character_ ;pdo i=1 to dim(cha); do i=1 to dim(cha); pif missing(chai) then output;if missing(chai) then output;pend;end;parray numarray num* * _numeri
10、c_ ; _numeric_ ;pdo i=1 to dim(num); do i=1 to dim(num); pif missing(numi) then output;if missing(numi) then output;pend;end;pdrop i;drop i;pproc print;proc print;prun;run;查找缺失值查找缺失值p缺失值結(jié)果缺失值結(jié)果查找重復(fù)值查找重復(fù)值pExcelExcel函數(shù):函數(shù):pcountif(countif(計(jì)數(shù)區(qū)域計(jì)數(shù)區(qū)域, ,條件條件 ) ) 根據(jù)指定條件,在計(jì)數(shù)區(qū)域內(nèi)計(jì)數(shù)根據(jù)指定條件,在計(jì)數(shù)區(qū)域內(nèi)計(jì)數(shù)查找重復(fù)值查找重復(fù)值pSA
11、SSAS命令:命令:pproc sort out=proc sort ; ;pby by 變量變量1 1 變量變量2 2 ; ;prun;run;查找重復(fù)值查找重復(fù)值pproc sortproc sort語(yǔ)句調(diào)用排序過(guò)程。選項(xiàng)語(yǔ)句調(diào)用排序過(guò)程。選項(xiàng)out=out=數(shù)據(jù)集指定排序數(shù)據(jù)集指定排序后的數(shù)據(jù)集名。因?yàn)榕判蚝髷?shù)據(jù)發(fā)生了變化,因此可指定后的數(shù)據(jù)集名。因?yàn)榕判蚝髷?shù)據(jù)發(fā)生了變化,因此可指定該選項(xiàng)將排序后的數(shù)據(jù)存放到一個(gè)新的數(shù)據(jù)集中。如果不該選項(xiàng)將排序后的數(shù)據(jù)存放到一個(gè)新的數(shù)據(jù)集中。如果不加該選項(xiàng),排序后的數(shù)據(jù)集將覆蓋原有數(shù)據(jù)集,這樣你就加該選項(xiàng),排序后的數(shù)據(jù)集將覆蓋原有數(shù)據(jù)集,這樣你就找不回原
12、有的未排序的數(shù)據(jù)了。找不回原有的未排序的數(shù)據(jù)了。p選項(xiàng)選項(xiàng)nodupkeynodupkey表示如果表示如果byby語(yǔ)句指定的排序變量有重復(fù)值,語(yǔ)句指定的排序變量有重復(fù)值,則刪除重復(fù)值。如按則刪除重復(fù)值。如按idid排序,如果排序,如果idid有重復(fù)值,則只保留有重復(fù)值,則只保留重復(fù)值中的第一個(gè)值,刪除其它值。重復(fù)值中的第一個(gè)值,刪除其它值。p選項(xiàng)選項(xiàng)nouniquekeynouniquekey的作用跟的作用跟nodupkeynodupkey正好相反,如果正好相反,如果byby語(yǔ)語(yǔ)句指定的排序變量都是唯一值,則將其刪除。如按句指定的排序變量都是唯一值,則將其刪除。如按idid排序排序,如果,如果
13、idid沒(méi)有有重復(fù)值,則全部刪除。沒(méi)有有重復(fù)值,則全部刪除。查找重復(fù)值查找重復(fù)值pbyby語(yǔ)句指定排序的變量,可以指定多個(gè)。選項(xiàng)語(yǔ)句指定排序的變量,可以指定多個(gè)。選項(xiàng)descendingdescending表示按降序排序,如果不加該選項(xiàng),表示按降序排序,如果不加該選項(xiàng),默認(rèn)的是按升序排序。默認(rèn)的是按升序排序。p當(dāng)需要查找重復(fù)值時(shí),當(dāng)需要查找重復(fù)值時(shí),byby語(yǔ)句指定的變量就是需語(yǔ)句指定的變量就是需要查找的重復(fù)值變量。要查找的重復(fù)值變量。查找重復(fù)值查找重復(fù)值pdata a1;data a1;pinput id g gender age marriage height weight nation;
14、input id g gender age marriage height weight nation;pcards;cards;p(數(shù)據(jù))(數(shù)據(jù))p;pproc sort proc sort nouniquekeynouniquekey out=bb; out=bb;pby genderby gender age marriage height weight;age marriage height weight;prun;run;pproc print data=bb;proc print data=bb;prun;run;查找重復(fù)值查找重復(fù)值p5 5個(gè)變量均重復(fù)的觀(guān)測(cè)個(gè)變量均重復(fù)的觀(guān)測(cè)查找
15、異常值查找異常值pExcelExcel函數(shù):函數(shù):pIfIf函數(shù)函數(shù)pIf(If(判斷條件判斷條件, ,條件滿(mǎn)足返回值條件滿(mǎn)足返回值, ,條件不滿(mǎn)足返回值條件不滿(mǎn)足返回值) )p結(jié)合各種算術(shù)運(yùn)算符、比較運(yùn)算符、邏輯運(yùn)算符等結(jié)合各種算術(shù)運(yùn)算符、比較運(yùn)算符、邏輯運(yùn)算符等查找異常值查找異常值p常見(jiàn)運(yùn)算符常見(jiàn)運(yùn)算符符號(hào)符號(hào)說(shuō)明說(shuō)明示例示例+和和-加減運(yùn)算加減運(yùn)算=3+2-4=1*和和/乘除運(yùn)算乘除運(yùn)算=3*2/4=1.5乘冪乘冪=32=9,=16(1/2)=4=、=、=等于、不等于等于、不等于大于、小于大于、小于大于等于、小于等于大于等于、小于等于=(A2=9),判斷,判斷A2是否等于是否等于9=(A
16、29),判斷,判斷A2是否不等于是否不等于9=(A2=9),判斷,判斷A2是否大于等于是否大于等于9and多個(gè)表達(dá)式同時(shí)成立多個(gè)表達(dá)式同時(shí)成立 and(A19,B19,B1(大于)、 =(大于等于)、 =(小于等于)in,表示其中之一,如grade in(2,4,6)表示只要是grade為2、4、6中的其中一個(gè)就算符合條件;dept not in(“A”, “B”)表示只要dept不是“A”或“B”就算成立&或and(表示2個(gè)表達(dá)式同時(shí)成立) | 或or(表示兩個(gè)表達(dá)式至少一個(gè)成立)查找異常值查找異常值pdata a1;data a1;pinput id g gender age ma
17、rriage height weight nation;input id g gender age marriage height weight nation;pcards;cards;p(數(shù)據(jù))(數(shù)據(jù))p;pdata b1;data b1;pset a1;set a1;pif if (gender not in(1,2) (gender not in(1,2) | | (age=60) (age=60) | | (height=200) (height=200) | | (weight=100) (weight=100) p| | (marriage not in (1,0) (marria
18、ge not in (1,0) | | (nation not in (1,2)(nation not in (1,2); ;pproc print;proc print;prun;run;查找異常值查找異常值查找異常值查找異常值pdata b2;data b2;pset a1;set a1;pif (gender not in(1,2,.) |if (gender not in(1,2,.) |p(age=. and (age=60) | (age=. and (age=60) | p(height=. and(height=200) |(height=. and(height=200) |
19、p(weight=. and (weight=100)| (weight=. and (weight=100)| pmarriage not in (1,0,.) | marriage not in (1,0,.) | pnation not in (1,2,.);nation not in (1,2,.);pproc print;proc print;prun;run;查找異常值查找異常值查找異常值查找異常值pdata data gendergender(where=(gender not in(1,2,.) (where=(gender not in(1,2,.) pageage(wher
20、e=(not missing(age) and(age=50) (where=(not missing(age) and(age=50) pmarriagemarriage(where=(marriage not in(1,0,.) (where=(marriage not in(1,0,.) pheightheight(where=(not missing(height) and(height=150 or (where=(not missing(height) and(height=200)height=200)pweightweight(where=(not missing(weight) and(weight=40 or (where=(not missing(weight) and(weight=100) weight=100) pnationnation(where=(nation not in(1,2,.) ;(where=(nation not in(1,2,.)
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- GB/T 45040-2024床上用品乳膠制品透氣性試驗(yàn)方法
- 易錯(cuò)題17 文言文閱讀之?dāng)嗑漕}-當(dāng)斷不斷不該斷卻斷【高考語(yǔ)文】備戰(zhàn)2025年高考易錯(cuò)題(新高考專(zhuān)用)含解析
- 愚人節(jié)活動(dòng)策劃方案 (15篇)
- 參觀(guān)圓明園的觀(guān)后感
- 智能大廈綜合布線(xiàn)的工程設(shè)計(jì)方案
- 青春追夢(mèng)人心共進(jìn)
- 多振源混疊的DAS目標(biāo)信號(hào)分離
- 智研咨詢(xún)發(fā)布:2024年中國(guó)美妝行業(yè)市場(chǎng)發(fā)展環(huán)境及前景研究報(bào)告
- DOPS基P-N-S協(xié)同阻燃劑的合成及其阻燃環(huán)氧樹(shù)脂的性能研究
- 二零二五版國(guó)際學(xué)校英語(yǔ)教師兼職外教聘請(qǐng)合同樣本3篇
- 房地產(chǎn)調(diào)控政策解讀
- 2024-2025學(xué)年八年級(jí)數(shù)學(xué)人教版上冊(cè)寒假作業(yè)(綜合復(fù)習(xí)能力提升篇)(含答案)
- 《AP內(nèi)容介紹》課件
- 醫(yī)生定期考核簡(jiǎn)易程序述職報(bào)告范文(10篇)
- 安全創(chuàng)新創(chuàng)效
- 鋼結(jié)構(gòu)工程施工(杜紹堂 第五版) 課件全套 單元1-3 緒論、材料與連接- 鋼結(jié)構(gòu)施工安全
- 門(mén)診診療指南及規(guī)范
- 2023《住院患者身體約束的護(hù)理》團(tuán)體標(biāo)準(zhǔn)解讀PPT
- 國(guó)外文化消費(fèi)研究述評(píng)
- 部編版語(yǔ)文四年級(jí)下冊(cè)第一單元 迷人的鄉(xiāng)村風(fēng)景 大單元整體教學(xué)設(shè)計(jì)
- 五年級(jí)行程問(wèn)題應(yīng)用題100道
評(píng)論
0/150
提交評(píng)論