Published on :
Statistics CREATION_INTERNE

Introduction Example for PROC HPMIXED

This code is also available in: Deutsch Español Français
Awaiting validation
This script generates a simulated dataset (Sim table) containing information on species, farms, and animals. It then uses the HPMIXED (High-Performance Mixed Models) procedure to fit a linear mixed model. The model evaluates yield (Yield) based on fixed effects (Species, Species*Farm Interaction) and a random effect (Animal). The code also includes hypothesis tests and contrast definitions.
Data Analysis

Type : CREATION_INTERNE


The data is entirely generated by the DATA 'Sim' step using loops and random functions (rannor, ranuni) to create 40,000 observations.

1 Code Block
DATA STEP Data
Explanation :
Creation of the 'Sim' working table. Use of arrays to store animal characteristics and generation of 40,000 simulated observations.
Copied!
1DATA Sim;
2 keep Species Farm Animal Yield;
3 array AnimalEffect{3000};
4 array AnimalFarm{3000};
5 array AnimalSpecies{3000};
6 DO i = 1 to dim(AnimalEffect);
7 AnimalEffect{i} = sqrt(4.0)*rannor(12345);
8 AnimalFarm{i} = 1 + int(100*ranuni(12345));
9 AnimalSpecies{i} = 1 + int(5*ranuni(12345));
10 END;
11 DO i = 1 to 40000;
12 Animal = 1 + int(3000*ranuni(12345));
13 Species = AnimalSpecies{Animal};
14 Farm = AnimalFarm{Animal};
15 Yield = 1 + Species + Farm/10 + AnimalEffect{Animal}
16 + sqrt(8.0)*rannor(12345);
17 OUTPUT;
18 END;
19RUN;
2 Code Block
PROC HPMIXED
Explanation :
Call to the HPMIXED procedure. Definition of classification variables, statistical model (MODEL), random effects (RANDOM), and specification of additional tests and contrasts.
Copied!
1PROC HPMIXED DATA=Sim;
2 class Species Farm Animal;
3 model Yield = Species Species*Farm;
4 random Animal;
5 test Species*Farm;
6 contrast 'Species1 = Species2 = Species3'
7 Species 1 0 -1,
8 Species 0 1 -1;
9RUN;
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.
Copyright Info : SAS SAMPLE LIBRARY