/* proc FrEQ proc freq data=zb_wejsc run; : Compress : Nlevels (liczba poziomow dla wszystkich zmiennych tables) : noprint - brak wydruku w oknie output : page - kazda tablica w osobnej stronie Missing - uwzglednia braki danych nocol - pomija procenty kolumnowe norow - pomija procenty wierszowe nofreq - pomija czestosci noprocent - pomija udzialy procentowe out noprint */ data zb_f; input lp1 lp2 plec $ nazwisko $ placa; label plec='płeć' placa='płaca'; cards; 1 1 K Domańska 2100 2 2 K Kowal 2800 3 3 K Nowak 3200 4 1 M Górski 4200 5 2 M Mazur 2500 6 3 M Kowalski 1800 ; run; proc freq data=zb_f; run; /* dla jednej zmiennej */ proc freq data=zb_f; table plec; run; proc freq data=zb_f; /* table plec placa; */ table plec / out=plec_t; table placa / out=placa_t; run; proc freq data=zb_f; tables plec*placa; run; proc freq data=zb_f; by plec; table placa*lp2; run; proc freq data=zb_f; tables plec*placa*lp2; run; proc sql; create table t as select count(distinct make) as n_make, count(distinct type) as n_type, count(distinct origin) as n_origin from sashelp.cars; quit; ods output nlevels=charlevels; proc freq data=sashelp.cars (keep = make type origin) nlevels; tables make type origin/ nopercent nocol nocum nofreq noprint; run; ods output close; /* PROC MEANS proc means data=zb_wejsc; by - zmienne klasyfikujace; class - zmienne klasyfikujace (nie wymaga sortowania i dla malych grup); freq zmienna z czestoscia; output lista_statystyk - N, MEAN, STD, MIN, MAX (NMISS, SUM, RANGE, VAR, MEDIAN, Qn); ways lista_liczb; */ proc means data=zb_f; run; /* z wyrzuceniem wynikow do tabeli SASOWEJ */ proc means data=zb_f noprint ; output out=zb_f_means; run; data zb_m; input lp rok miesiac dochod zmiana; label miesiac="miesiąc" dochod='dochód'; cards; 1 2006 1 500000 0 2 2006 2 520000 20000 3 2006 3 480000 40000 4 2007 1 530000 50000 5 2007 2 570000 40000 6 2007 3 550000 20000 ; run; proc means data=zb_m mean; by rok; var zmiana; output out=wyn_m mean=; format zmiana 8.2; run; proc means data=zb_m; class rok miesiac; output out=wyn_2 mean(dochod)=sredni_dochod; run; proc means data=zb_m nway noprint; class rok miesiac; output out=wyn_3 mean(dochod)=sredni_dochod; run; proc means data=zb_m mean; class rok miesiac; var dochod; ways 1 2; run; proc means data=zb_m mean; class rok miesiac; var dochod; types rok miesiac rok*miesiac; run; /* Proc univariate */ proc univariate data=sashelp.shoes; var sales; run; /* analiza z grupowaniem */ proc univariate data=sashelp.shoes; var sales; class region; run; proc univariate data=sashelp.shoes; var sales; by region; run; ods select Moments; /* BasicMeasures, TestForLocation, Quantiles, ExtremeObs */ proc univariate data=sashelp.shoes; var sales; class region; run; /* uruchom i sprawdz log */ ods trace on; proc univariate data=sashelp.shoes; var sales; class region; run; ods trace off; /* jeżeli chcesz zapisać do tablicy sas */ ods output Quantiles=temp; proc univariate data=sashelp.shoes; var sales; class region; run; ods output close; ods output extremeobs=outlier; proc univariate data=sashelp.shoes; var sales; class region; run; ods output close; /* weryfikacja normalności rozkładu - histogram plot - skosnosc - testy */ proc univariate data=sashelp.shoes noprint; var sales; histogram / normal(color=red); run; /* skosnosc na poziomie -0.5 do 0.5 - rozklad symetryczny lub normalny */ ods select Moments; proc univariate data=sashelp.shoes; var sales; run; /* testy normalności */ ods select TestsforNormality; proc univariate data=sashelp.shoes normal; var sales; run; /* dowolne percentyle */ proc univariate data=sashelp.shoes noprint; var sales; output out=temp pctlpre=P_ pctlpts=10 to 100 by 10; run; proc univariate data=sashelp.shoes plot; var sales; run; /* GRAFIKA */ data temp; set sashelp.class; run; /*BAR CHART */ title "Waga Studentow"; proc gchart data=temp; hbar name / type=sum sumvar=weight; run; title "Waga Studentow"; proc gchart data=temp; vbar name / type=sum sumvar=weight; run; /* etykiety */ title "Waga Studentow"; footnote 'wykresik z etykietami'; proc gchart data=temp; vbar name / type=sum sumvar=weight outside=sum /* inside=sum */ ; run; title "Waga Studentow"; footnote 'wykresik z etykietami'; proc gchart data=temp; vbar name / type=sum sumvar=weight descending outside=sum ; run; title "Waga Studentow"; goptions htext=13pt htitle=15pt; axis1 label=none; axis2 label="Waga w funtach"; proc gchart data=temp; vbar name / type=sum sumvar=weight descending maxis=axis1 raxis=axis2 ; run; quit; title "Avarege Male and Female Weights"; goptions htext=13pt htitle=15pt; axis1 label=none value(f="Arial/Bold" "Female" "Male"); axis2 label=(a=90 f="Arial/Bold" 'Mean Weight in Pounds') order=(0 to 150 by 25) minor=none offset=(0,0); pattern1 value=solid color=pink; pattern2 value=solid color=cx42c0fb; proc gchart data=temp; vbar sex / width=25 type=mean sumvar=weight descending maxis=axis1 raxis=axis2 outside=mean coutline=gray subgroup=sex; run; quit; title 'zgrupowany bar chart'; axis1 label=('MSRP') minor=none offset=(0,0); axis2 label=none; axis3 label=none offset=(7,7); proc gchart data=sashelp.cars; vbar type / discrete type=mean sumvar=msrp group=origin coutline=grey raxis=axis1 maxis=axis2 gaxis=axis3 noframe; run; quit; title ; axis1 label=('MSRP') minor=none offset=(0,0); axis2 lable=none offest=(7,7); proc gchart data=sashelp.cars; vbar type /discrete type=mean sumvar=msrp subgroups=origin countline=grat width=10 raxis=axis1 maxis=axis2 nofrme; run; quit; title; goptions htext=10pt htitle=12pt; proc gchart data=temp; vbar weight/ space=1 width=10 outside=freq levels=4 range; run;quit; title 'line chart'; symbol1 value=noen interpol=sm color=blue; proc gplot data=sashelp.failure; where cause="Contamination" and process="Process A"; plot count*day; run; quit; title 'scatter plot'; symbol1 value=circle height=3 interpol=none color=blue; symbol2 value=circle height=3 interpol=none color=red; proc gplot data=temp; plot height*weight=sex; run; /* ANALIZA STATYSTYCZNA */ /*przygotowanie danych*/ data dane; do id=1 to 3000; x=rannor(1); y=ranuni(1); z=rannor(1)*10+10; u=x; if id=100 then u=1000; v=rannor(1)*rannor(1)*rannor(1); stala=1; output; end; run; /*przygotowanie danych*/ *ogladanie; proc print data=dane(obs=10); run; *podstawowe statystyki; proc means data=dane maxdec=3; var x y; run; *Troche wiecej i wspolczynnik zmiennosci i centyle i skrajne; proc univariate data=dane; var x y z u; id id; run; *wszystkie centyle; proc univariate data=dane noprint; var x y; id id; output out=centyle pctlpre=Px_ Py_ pctlpts=1 to 100 by 1; run; proc print; run; *czym różnią się rozkłady zmiennych x i u?; proc univariate data=dane; var x u; id id; run; proc gchart data=dane; vbar3d x / levels=10; vbar3d u / levels=10; run; quit; /*testy zodnosci z rozkładem*/ proc univariate data=dane; var x u; id id; histogram x u / normal; inset normal(sigma mean) / position=ne; run;