Sitemap
BHornink

BHornink

Exploratory analysis

2 min readMay 18, 2023
*Defining the characteristics of the report that will be in Word format*; 
ods rtf style = journal file = "C: [caminho do arquivoo]/ [nome do arquivo.rtf]"; /*inserindo um caminho para salvar o relatório em formato word*/
ods html close; ods html;
title "PROC FREQ"; /*gives a title to the report*/
footnote "Fonte: SAS Help and Documentation"; /*inserts a footnote at the bottom of the report*/
options nodate nonumber; /*removes date and page numbers from the report*/
ods noptitle; /*removes the procedure name from the report*/
​
*Creating a dataframe*;
data summerschool;
input gender $ internship $ enrollment $ count @@; /*The @@ symbol is used in SAS programming to enable reading data in a sequential line-by-line manner.
By using @@ at the end of an input statement, SAS will read the next input line immediately after the current line, rather than advancing to the next line as it normally would.
This allows for more complex data reading scenarios where multiple observations may be present on a single line or where specific conditions need to be met before advancing to the next line of input.*/
label
gender = " Gender"
internship = " Internship"
enrollment = " Enrollment"
count = " Total";
datalines;
boys yes yes 35 boys yes no 29
boys no yes 14 boys no no 27
girls yes yes 32 girls yes no 10
girls no yes 53 girls no no 23
;

*print dataframe*;
proc print data = summerschool noobs label;
run;

​*frequency procedure, PROC FREQ, provides basic statistics for categorical variables.*;
*chisq = chi-squared
-Non-parametric test for comparing proportions
-Quantitative assessment of the relationship between the outcome of an experiment and the expected distribution for the phenomenon
-Requires a minimum of 5 observations
-H0 (null hypothesis): There is no association between the groups
-Ha (alternative hypothesis): There is an association between the groups*;

​title2 "Exemple 01";
proc freq data=summerschool order=data;
tables internship*enrollment / chisq;
weight count;
run;

​*Results*
*The frequency procedure table presents the tabulation of data between Stage and Enrolled.
Data Order:
-Sum = Frequency
-Percentage of Total
-Percentage of Row Total
-Percentage of Column Total*;

*Chi-Square Statistics Table
-Provides various tests that assess the proportion between evaluated treatments, with the most common being Chi-Square and Likelihood Ratio Chi-Square (used for small samples)
-Pearson Chi-Square = 0.8189, and the p-value is 0.3655. This indicates that the enrollment and stage data do not show a significant association. Therefore, the null hypothesis (H0) is accepted*;

*Generating the data by dividing the frequency of stage by enrollment based on gender*;
ods graphics on;
title2 "Exemplo 02";
proc freq data=summerschool;
tables gender*internship*enrollment /
chisq cmh plots(only)=freqplot(twoway=cluster);
weight count;
run;
ods graphics off;
ods rtf close;

--

--