BookmarkSubscribeRSS Feed
trekvana
Calcite | Level 5
hello all-

how do i specify which the subject i want to use to estimate my random effects. for example say i have 160 subjects and i do:

proc mixed;
class subjects;
model y=time;
random intercept time/ sub=subjects type=un;
estimate "60th subject slope" int 1 | int 1 / sub 60;
run;

this doesnt give what i want. the only way i know to give me the 60th subject is to say

estimate "60th subject slope" int 1 | int 1 / sub 0 0 0 0.....0 1;
where we have 59 zeros and then a 1 for the 60th subject.

im assuming its the same with the contrast statement. there must be a faster and better way right?

Message was edited by: trekvana
2 REPLIES 2
Dale
Pyrite | Level 9
The only way that I know of to specify the 60th subject would be to issue 59 0 values and then a 1 for the 60th subject. I am having trouble trying to figure out why you would want to that, but that is for another day.

In order to implement something like selecting the 60th subject, I would use a macro to generate the subject specification coefficients. Accordingly, you could code:

%macro SubSpecEst(subject=);
  %let length_subj=%sysfunc(length(&subject));
  %let lastdigit=%sysfunc(substr(&subject,&length_subj));
  %if &lastdigit=1 %then %let superscript=st; %else
  %if &lastdigit=2 %then %let superscript=nd; %else
  %if &lastdigit=3 %then %let superscript=rd; %else
                                   %let superscript=th;
  estimate "&subject.&superscript. subject slope" time 1 | time 1 / subject
               %do i=1 %to %eval(&subject.-1); 0%end; 1;
%mend SubSpecEst;

(Note that I changed your intercept specification in the estimate statement to a time specification because the label indicated the slope for the 60th subject.)

With this macro, one would then write:

proc mixed;
  class subjects;
  model y=time;
  random intercept time/ sub=subjects type=un;
  %SubSpecEst(subject=60)
run;
trekvana
Calcite | Level 5
Thanks Dale!

The reason I wanted to know how to do this was just in case I ever needed to know how to do that I wouldnt be scrambling at last minute to figure it out

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1479 views
  • 0 likes
  • 2 in conversation