turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- Analytics
- /
- Stat Procs
- /
- proc mixed estimate and contrast statement

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

09-22-2010 03:27 PM

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

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;

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to trekvana

09-23-2010 05:00 PM

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;

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;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Dale

09-23-2010 08:18 PM

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

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