Published on :
Général CREATION_INTERNE

Sans titre

This code is also available in: Deutsch Español Français
Awaiting validation
Data Analysis

Type : CREATION_INTERNE


Data is manually created via the DATALINES statement in the first DATA step.

1 Code Block
DATA STEP Data
Explanation :
Creation of the 'cash' dataset containing two variables: School (group) and Money (numeric value).
Copied!
1DATA cash;
2 INPUT School Money;
3 
4DATALINES;
50 34
60 1200
70 23
80 50
90 60
100 50
110 0
120 0
130 30
140 89
150 0
160 300
170 400
180 20
190 10
200 0
211 20
221 10
231 5
241 0
251 30
261 50
271 0
281 100
291 110
301 0
311 40
321 10
331 3
341 0
35;
2 Code Block
PROC TTEST
Explanation :
Execution of the initial Student's t-test on observed data to calculate the actual mean difference between groups.
Copied!
1PROC TTEST DATA=cash;
2 class School;
3 *may need to convert School to numeric;
4 var Money;
5RUN;
3 Code Block
PROC IML Data
Explanation :
Using the IML matrix language to read data, generate 1000 random permutations of the 'Money' column (resampling without replacement) and create a large 'newds' table containing the original groups and the 1000 permuted vectors.
Copied!
1ods OUTPUT off;
2ods exclude all;
3 
4PROC IML ;
5 use cash;
6 read all var{School Money} into x;
7 p=t(ranperm(x[, 2], 1000));
8 paf=x[, 1]||p;
9 create newds from paf;
10 append from paf;
11 QUIT;
4 Code Block
PROC TTEST Data
Explanation :
Massive execution of t-tests on the 1000 permuted columns (col2 to col1001) against the group (col1). Results (confidence limits/differences) are captured in the 'diff' table via ODS OUTPUT.
Copied!
1ods OUTPUT conflimits=diff;
2 
3PROC TTEST DATA=newds plots=none;
4 class col1;
5 var col2 - col1001;
6RUN;
7 
8ods OUTPUT on;
9ods exclude none;
5 Code Block
PROC UNIVARIATE
Explanation :
Analysis of the distribution of mean differences (variable 'mean' in the output table 'diff') obtained by permutation, with histogram generation.
Copied!
1PROC UNIVARIATE DATA=diff;
2 where method="Pooled";
3 var mean;
4 histogram mean;
5RUN;
6 Code Block
DATA STEP Data
Explanation :
Filtering permutations whose mean difference is as extreme or more extreme than the observed difference (hardcoded here at 114.6). The resulting number of observations divided by 1000 gives the estimated p-value.
Copied!
1DATA numdiffs;
2 SET diff;
3 where method="Pooled";
4 
5 IF abs(mean) >=114.6;
6RUN;
7 
8PROC PRINT DATA=numdiffs;
9 where method="Pooled";
10RUN;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.