2017-07-19 5 views
0

これは初めてのことで、すでにこの質問を掲載しています。しかし、私はそれをうまく説明していないと思う。私の結果で不足している周波数を乗り越えるには

私はSASの中にDATAを持っています。 一部のセルは空で[何も入っていません]、SAS出力ウィンドウではセル内にDOTがあります。 WHERE私は結果を実行します。テーブルの終わりに、それはMISSING FREQUENCY = 7か何か番号を追加します...

どのようにしてSASが不足する頻度を無視し、結果のあるもののみを使用しますか? .. 私のスクリーンショット、コードと私のCSVをご覧ください。OUTPUT DATA

RESULT WITH the MISSING frequency at the bottom

/* Generated Code (IMPORT) */ 
/* Source File:2012_16_ChathamPed.csv */ 
/* Source Path: /home/cwacta0/my_courses/Week2/ACCIDENTS */ 
PROC IMPORT 
     DATAFILE='/home/cwacta0/my_courses/Week2/ACCIDENTS/2012_16_ChathamPed.csv' 
     OUT=imported REPLACE; 
    GETNAMES=YES; 
    GUESSINGROWS=32767; 
RUN; 

proc contents data=work.imported; 
run; 

libname mydata"/courses/d1406ae5ba27fe300" access=readonly; 
run; 

/* sorting data by location*/ 
PROC SORT ; 
    by LocationOfimpact; 
    LABEL Route="STREET NAME" Fatalities="FATALITIES" Injuries="INJURIES" 
     SeriousInjuries="SERIOUS INJURIES" LocationOfimpact="LOCATION OF IMPACT" 
     MannerOfCollision="MANNER OF COLLISION" 
     U1Factors="PRIMARY CAUSES OF ACCIDENT" 
     U1TrafficControl="TRAFFIC CONTROL SIGNS AT THE LOCATION" 
     U2Factors="SECONDARY CAUSES OF ACCIDENT" 
     U2TrafficControl="OTHER TRAFFIC CONTROL SIGNS AT THE LOCATION" 
     Light="TYPE OF LIGHTHING AT THE TIME OF THE ACCIDENT" 
     DriverAge1="AGE OF THE DRIVER" DriverAge2="AGE OF THE CYCLIST"; 

    /* Here I was unable to extract the drivers age 25 or less and te drivers who disregarded stop sign. here is how I coded it; 
    IF DriverAge1 LE 25; 
    IF U1Factors="Failed to Yield" OR U1Factors= "Disregard Stop Sign"; 
    Run; 

    Also, I want to remove the Missing DATA under the results. But in the data, those are just a blank cell. How do I tell SAS to disregard a blank cell and not add it to the result? 
    Here is what I did and it does not work... 

    if U1Factors="BLANK" Then U1Factors="."; 
    Please help me figre this out...Tks 

    IF U1Factors="." Then call missing(U1Factors)*/; 

Data want; 
    set imported; 

    IF DriverAge1 LE 25 And U1Factors in ("Failed to Yield", "Wrong Side of Road", 
     "Inattentive"); 

    IF Light in ("DarkLighted", "DarkNot Lighted", "Dawn"); 
run; 

proc freq ; 
    tables /*Route Fatalities Injuries SeriousInjuries LocationOfimpact MannerOfCollision*/ 
    U1Factors /*U1TrafficControl U2Factors U2TrafficControl*/ 
    light DriverAge1 DriverAge2; 
RUN; 
+0

あなたは結果として何をしたいのかを指定していません。私はそれも投稿することをお勧めします。 – Reeza

+0

PROC SORTとDATAの間にIFステートメントがあるのはなぜですか? – Tom

答えて

0

SASは、期間を使用して数値変数を逃し表示されます。したがって、CSVファイルのDriverAge1の列に何もない場合、その観測値には値がありません。変数が文字の場合、SASは通常、入力ストリーム内の単なる値をSAS変数の空白に変換します。

欠落している数値は、任意の実数よりも小さいとみなされます。したがって、あなたが他の何らかの条件によってそれらを除外しないと、欠損値以下のような使用条件が含まれることになります。

procsでWHERE文を使用してデータをフィルタできます。別のステートメントでWHERE条件に追加する場合は、WHERE ALSO構文を使用して余分な条件を追加することができます。

PROC FREQ出力に欠落したカテゴリを表示するには、MISSPRINTオプションをTABLESステートメントに追加します。または、MISSINGオプションを追加すると、それが表示され、統計にもカウントされます。

proc freq ; 
    where . < DriverAge1 <= 25 
    and U1Factors in ("Failed to Yield", "Wrong Side of Road","Inattentive") 
    ; 
    where also Light in ("DarkLighted", "DarkNot Lighted", "Dawn"); 
    tables U1Factors light DriverAge1 DriverAge2/missing; 
run; 

WHERE条件はデータセット全体に適用されます。あなたがDriverAge1を行方不明と行方不明U1Factors

proc freq ; 
    where not missing(U1Factors) and not missing(DriverAge1); 
    tables U1Factors DriverAge1 ; 
run; 

を除外するのであれば、両方のために欠落していない唯一の観測が含まれます。したがって、変数ごとに個別に統計を生成することができます。

proc freq ; 
    where not missing(U1Factors); 
    tables U1Factors ; 
run; 
proc freq ; 
    where not missing(DriverAge1); 
    tables DriverAge1 ; 
run; 
+0

トムありがとう。感覚を作る.. –

関連する問題