1 / 12

INPUT 指令 讀入資料

INPUT 指令 讀入資料. INPUT 指令的目的 是將原始資料解釋成 變項值 INPUT 撰寫方式 1. List input 2. Column input 3. Formatted input. LIST INPUT 指令撰寫方式. LIST INPUT 簡列讀入法 INPUT name $ sex $ age ht wt q1-q20; 文字變項後須用 $ 宣告 連續的變項只要列 首-尾

Download Presentation

INPUT 指令 讀入資料

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. INPUT 指令 讀入資料 • INPUT 指令的目的 是將原始資料解釋成 變項值 • INPUT 撰寫方式1. List input2. Column input3. Formatted input

  2. LIST INPUT 指令撰寫方式 • LIST INPUT 簡列讀入法INPUT name $ sex $ age ht wt q1-q20; • 文字變項後須用 $ 宣告 • 連續的變項只要列 首-尾 • 資料間 1. 必留空格 2. 缺漏值用(.) , 不可空格 3. 變項值和INPUT變項列順序一致 4. 文字變項不可含空格

  3. COLUMN INPUT 指令撰寫方式 • COLUMN INPUT 欄位讀入法INPUT name $ 1-10 sex $ 11age 13-14 ht 16-18 wt 20-22 ; • 1.文字變項後須用$宣告 值長度可達200字母 2. 缺漏值用(.) , 亦可用空格表示 3. 變項值依變項資料檔既定位置 4. 文字變項可含空格 5. 變項值可任何順序來讀取 6. 數據可重複讀取

  4. FORMATTED INPUT 撰寫方式 • FORMATTED INPUT 格式讀入法INPUT name $ 10. @12 sex $ 1. +5age 2.+3 ht ; • 1.文字變項後須用$宣告 2.變項讀取根據讀取指標INDEX及讀取格式INFORMATS而定 3.連續的變項可共享括號內相同的讀取格式

  5. FORMATTED INPUT 撰寫方式 • INPUT #1 name $ 10. /@1 income E7. #3 tax 6.2 ; • INPUT name $ @12 sex $ 1. +3 addrs $ 13-25 +3 age 2. @30 income COMMA 7.2 ; • INPUT name $ 10. (q1-q20)(1.) ;

  6. 讀取指標 INDEX • @n • +n • #n • /

  7. 讀取格式INFORMATS • W. /*數值變項的長度eg. Age 2. */ • W.d /*數值變項的長度及小數點位數 */ • $ w. /*文字變項的長度eg. name $ 20.*/ • Ew.d /*科學記號之數值變項的長度*/ • BZw.d /*數值變項中空白變成0 */ • COMMAw.d /* Income COMMA10.2 */

  8. 建構SAS資料檔的其它方法 • 多筆記錄整合成一個觀測體(1) / /input name $ 10. / income E7. / tax 6.2;(2)# #input #3 tax 6.2 #2 income E.7 #1 name $ 10. ;(3); ; ;input name $ 10.;input income E7.;input tax 6.2;

  9. 建構SAS資料檔的其它方法 • 單一記錄中讀取多個觀測體DATA a;input group $ score @@;datalines;1 60 1 70 1 802 95 2 55 2 653 79 3 89 3 99;

  10. 建構SAS資料檔的其它方法 • 依據記錄內涵 區分資料DATA a;input type $ 1. @;if type=‘c’ then input name $ pop comma10.2;else if type=‘r’ then input incomec10.2 tax 6.2;datalines;c sinchuang 8000c sanchong 19520r 79389 3520r 65000 20000 ;

  11. 建構SAS資料檔的其它方法 • 數個變項共用相同讀入格式 • input (a1-a10)(1.) (b1-b10)(1.); • input (a1-a10, b1-b10)(20*1.); • input (a1-a10, b1-b10)(1.) (q1-q5) ($); • input (x1-x4)(+2 3. +3 $5.) (x5-x10)(2. +1) ;

  12. 建構SAS資料檔的其它方法 • MISSOVER選項的用途 • DATA miss;INFILE DATALINES MISSOVER;INPUT name $ item1-item5;DATALINES;A 1 2 3B 5 5 5 5 5 C 2 2 2 2 2;

More Related