在SAS中創(chuàng)建散點圖的基本語法是:
PROC sgscatter DATA=DATASET; PLOT VARIABLE_1 * VARIABLE_2 / datalabel = VARIABLE group = VARIABLE; RUN;
以下是使用的參數(shù)的描述:
在一個簡單的散點圖中,我們從數(shù)據(jù)集中選擇兩個變量,并根據(jù)第三個變量對它們進(jìn)行分組。 我們還可以標(biāo)記數(shù)據(jù)。 結(jié)果顯示兩個變量如何分散在笛卡爾平面中。
PROC SQL; create table CARS1 as SELECT make,model,type,invoice,horsepower,length,weight FROM SASHELP.CARS WHERE make in ('Audi','BMW') ; RUN; TITLE 'Scatterplot - Two Variables'; PROC sgscatter DATA=CARS1; PLOT horsepower*Invoice / datalabel = make group = type grid; title 'Horsepower vs. Invoice for car makers by types'; RUN;
當(dāng)我們執(zhí)行上面的代碼,我們得到以下的輸出:
我們可以使用估計參數(shù)通過圍繞值繪制橢圓來預(yù)測相關(guān)性的強(qiáng)度。 我們使用過程中的附加選項來繪制橢圓,如下所示。
proc sgscatter data =cars1; compare y = Invoice x =(horsepower length) / group=type ellipse =(alpha =0.05 type=predicted); title 'Average Invoice vs. horsepower for cars by length'; title2 '-- with 95% prediction ellipse --' ; format Invoice dollar6.0; run;
當(dāng)我們執(zhí)行上面的代碼,我們得到以下的輸出:
我們還可以有一個散點圖,通過將它們分組成對,涉及多于兩個變量。 在下面的示例中,我們考慮三個變量并繪制散點圖矩陣。 我們得到3對結(jié)果矩陣。
PROC sgscatter DATA=CARS1; matrix horsepower invoice length / group = type; title 'Horsepower vs. Invoice vs. Length for car makers by types'; RUN;
更多建議: