實(shí)驗(yàn)一SAS系統(tǒng)及數(shù)據(jù)集創(chuàng)建_第1頁
實(shí)驗(yàn)一SAS系統(tǒng)及數(shù)據(jù)集創(chuàng)建_第2頁
實(shí)驗(yàn)一SAS系統(tǒng)及數(shù)據(jù)集創(chuàng)建_第3頁
實(shí)驗(yàn)一SAS系統(tǒng)及數(shù)據(jù)集創(chuàng)建_第4頁
實(shí)驗(yàn)一SAS系統(tǒng)及數(shù)據(jù)集創(chuàng)建_第5頁
已閱讀5頁,還剩6頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、實(shí)驗(yàn)一 SAS 系統(tǒng)及數(shù)據(jù)集創(chuàng)建一、實(shí)驗(yàn)?zāi)康?了解 SAS 邏輯庫組成,創(chuàng)建。學(xué)習(xí) SAS 數(shù)據(jù)集(數(shù)據(jù)文件,數(shù) 據(jù)視窗的命名,創(chuàng)建。學(xué)習(xí)數(shù)據(jù)集導(dǎo)入導(dǎo)出,變量定義,變量選擇,觀測選擇 等操作,缺失值插值。二、 實(shí)驗(yàn)內(nèi)容(1用戶用 SAS 數(shù)據(jù)步(DA TA STEP創(chuàng)建一個(gè)數(shù)據(jù)集的方法, DA TA 程序步的主要步驟 : Data 所要?jiǎng)?chuàng)建的數(shù)據(jù)集名 ;Infile 讀取的外部文件名 < FIRSTOBS=開始讀入的行 >< OBS=結(jié)束行 > ;Input 變量 1 讀入模式 變量 2 讀入模式 ;Run ;(2 確定變量的讀入模式共有四種:column 模式Inpu

2、t 變量 1 < $> 開始列 <-結(jié)束列 ><.小數(shù)位 > 變量 2 ;例 1:data testd1;infile 'e:dmydirtestdata.dat' firstobs=2 obs=4;input code $1-8 sex $9 bdata $10-16 income 17-23 .2; run;上面的程序的數(shù)據(jù)步在臨時(shí)庫 WORK 中創(chuàng)建了 SAS 數(shù)據(jù)集 work.testd1, 而過程步 PRINT 則顯示該數(shù)據(jù)集。formatted 模式格式一:Input <指針控制 > 變量 1 輸入格式 <|&g

3、t; ;格式二:Input <指針控制 > (變量表 (輸入格式表 <|> ;例 2:Data testd2 ;Infile e:dmydirtestdata.dat ;Input code $ 1-8 sex $ 9 ;Input bdate $ 10-16 income $17-23 .2 ;Proc printdata=testd2 ;Run; list 模式格式一:Input <指針控制 > 變量 1 <$><&> <|> ;格式二:Input <指針控制 > 變量 1 <:|&|

4、> <輸入格式 > <|> ;例 3:Data testd5 ;Infile e:dmydirtestdata2.txt dsd;Input name & $15. age address $40. pc ;Proc print data=testd5 ;Run ; 例 4:data A600001(label="邯鄲鋼鐵 "input date yymmdd10. oppr hipr lopr clpr vol sums name $ hstocd $; format date yymmdd10. ; /*設(shè)定變量的輸出格式 */la

5、bel Date="日期 |Date" /*給變量加標(biāo)簽 */label Oppr="開盤價(jià) |Open Price"cards; /*以下是數(shù)據(jù)表 */2001-1-16 8.08 8.4 8.05 8.35 45571 37683964 邯鄲鋼鐵 6000012001-1-17 8.39 8.5 8.28 8.29 26345 22076348 邯鄲鋼鐵 6000012001-1-18 8.32 8.4 8.21 8.26 17854 14844434 邯鄲鋼鐵 600001 4、增加變量、選擇變量和觀測創(chuàng)建新數(shù)據(jù)集例 5:Data class2 ;

6、Input id test1-test5 ;average=mean(test1,test2,test3,test4,test5;test4=test1+test2+test3+test4+test5;Cards ;980801 100 100 100 100 100980802 90 100 90 100 90980803 81 82 83 84 85Proc print data=class2 ;Run ;Input id test1-test5 ; 輸入數(shù)據(jù)average=mean(test1,test2,test3,test4,test5; 求 test1到 test5的平均值test

7、4=test1+test2+test3+test4+test5; 例 6:Data class3 (drop=test1 test2 test3 test4 test5 ;Set class2 ;Proc print data=class3 ;Run;創(chuàng)建 class3 數(shù)據(jù)集,數(shù)據(jù)來源是 class2 中剔除 test1 test2 test3 test4 test5 例 7:Data class4 ;Set class2 ;if average>=80 and (100=test1 or 100=test2 or 100=test3 or 100=test4 or 100=test5

8、 ;Proc printdata=class4 ;Run ;創(chuàng)建數(shù)據(jù)集 class3, 數(shù)據(jù)來源是 class2中均值 >=80, 且 test 1test 5中有一值 為 100. 三、習(xí)題1、下列為 1975-1980年夏威夷島莫納羅亞火山每月釋放 CO2的數(shù)據(jù),請將它生 成數(shù)據(jù)集 H1,并剔除釋放量小于 330的觀測,生成新的數(shù)據(jù)集 H2。330.45 330.97 331.64 332.87 333.61 333.55331.90 330.05 328.58 328.31 329.41 330.63 331.63 332.46 333.36 334.45 334.82 334.3

9、2 333.05 330.87 329.24 328.87 330.18 331.50 332.81 333.23 334.55 335.82 336.44 335.99 334.65 332.41 331.32 330.73 332.05 333.53 334.66 335.07 336.33 337.39 337.65 337.57 336.25 334.39 332.44 332.25 333.59 334.76 335.89 336.44 337.63 338.54 339.06 338.95 337.41 335.71 333.68 333.69 335.05 336.53 337.

10、81 338.16 339.88 340.57 341.19 340.87 339.25 337.19 335.49 336.63 337.74 338.36 Data H1 ;Input id test1-test6;Cards ;330.45 330.97 331.64 332.87 333.61 333.55 331.90 330.05 328.58 328.31 329.41 330.63 331.63 332.46 333.36 334.45 334.82 334.32 333.05 330.87 329.24 328.87 330.18 331.50 332.81 333.23 3

11、34.55 335.82 336.44 335.99 334.65 332.41 331.32 330.73 332.05 333.53 334.66 335.07 336.33 337.39 337.65 337.57 336.25 334.39 332.44 332.25 333.59 334.76 335.89 336.44 337.63 338.54 339.06 338.95 337.41 335.71 333.68 333.69 335.05 336.53 337.81 338.16 339.88 340.57 341.19 340.87 339.25 337.19 335.49

12、336.63 337.74 338.36 Proc print data =H1 ;Run ;運(yùn)行結(jié)果:co2time330.451975/1/1330.971975/2/1331.641975/3/1332.871975/4/1333.611975/5/1333.551975/6/1331.91975/7/1330.051975/8/1330.631975/12/1331.631976/1/1332.461976/2/1333.361976/3/1334.451976/4/1334.821976/5/1334.321976/6/1333.05 330.87 330.18 331.5 332.

13、81 333.23 334.55 335.82 336.44 335.99 334.65 332.41 331.32 330.73 332.05 333.53 334.66 335.07 336.33 337.39 337.65 337.57 336.25 334.39 332.44 332.25 333.59 334.76 335.89 336.44 337.63 338.54 339.06 338.95 337.41 335.71 333.68 333.69 335.05 336.53 337.81 338.16 1976/7/1 1976/8/1 1976/11/1 1976/12/1

14、1977/1/1 1977/2/1 1977/3/1 1977/4/1 1977/5/1 1977/6/1 1977/7/1 1977/8/1 1977/9/1 1977/10/1 1977/11/1 1977/12/1 1978/1/1 1978/2/1 1978/3/1 1978/4/1 1978/5/1 1978/6/1 1978/7/1 1978/8/1 1978/9/1 1978/10/1 1978/11/1 1978/12/1 1979/1/1 1979/2/1 1979/3/1 1979/4/1 1979/5/1 1979/6/1 1979/7/1 1979/8/1 1979/9

15、/1 1979/10/1 1979/11/1 1979/12/1 1980/1/1 1980/2/1 339.88 340.57 341.19 340.87 339.25 337.19 335.49 336.63 337.74 338.36 1980/3/1 1980/4/1 1980/5/1 1980/6/1 1980/7/1 1980/8/1 1980/9/1 1980/10/1 1980/11/1 1980/12/1 2、1945 年-1950 年費(fèi)城月度降雨量數(shù)據(jù)如下(單位:mm) 。 生成數(shù)據(jù)集 H3。 330.45 330.97 331.64 332.87 333.61 333.5

16、5 331.90 330.05 328.58 328.31 329.41 330.63 331.63 332.46 333.36 334.45 334.82 334.32 333.05 330.87 329.24 328.87 330.18 331.50 332.81 333.23 334.55 335.82 336.44 335.99 334.65 332.41 331.32 330.73 332.05 333.53 334.66 335.07 336.33 337.39 337.65 337.57 336.25 334.39 332.44 332.25 333.59 334.76 335.

17、89 336.44 337.63 338.54 339.06 338.95 337.41 335.71 333.68 333.69 335.05 336.53 337.81 338.16 339.88 340.57 341.19 340.87 339.25 337.19 335.49 336.63 337.74 338.36 data h3; input hight; time=intnx('month','01jan1945'd,_n_-1; format time mmddyy10; cards; 330.45 330.97 331.64 332.87 33

18、3.61 333.55 331.90 330.05 328.58 328.31 329.41 330.63 331.63 332.46 333.36 334.45 334.82 334.32 333.05 330.87 329.24 328.87 330.18 331.50 332.81 333.23 334.55 335.82 336.44 335.99 334.65 332.41 331.32 330.73 332.05 333.53 334.66 335.07 336.33 337.39 337.65 337.57 336.25 334.39 332.44 332.25 333.59 3

19、34.76 335.89 336.44 337.63 338.54 339.06 338.95 337.41 335.71 333.68 333.69 335.05 336.53 337.81 338.16 339.88 340.57 341.19 340.87 339.25 337.19 335.49 336.63 337.74 338.36 ; proc print data=h3; run; hight 330.45 time -5478 330.97 331.64 332.87 333.61 333.55 331.9 330.05 328.58 328.31 329.41 330.63 331.63 332.46 333.36 334.45 334.82 334.32 333.05 330.87 329.24 328.87 330.18 331.5 332.81 333.23 334.55 335.82 336.44 335.99 334.65 332.41 331.32 330.73 332.05 333.53 334.66 335.07 336.33 33

溫馨提示

  • 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)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論