## How to write SAS program for residual transformation on self-paced reading data

Solved
Occasional Contributor
Posts: 6

# How to write SAS program for residual transformation on self-paced reading data

I'm using SAS 9.4.

I have data for about 50 participants, who each read a series of sentences that have the same structure. The reading time (in milliseconds) for each word in each sentence was recorded. I want to get a regression line for how the word length (in characters) relates to reading time for each participant, and I want to then convert the reading time measurement into the corresponding residual from these regression equations for each data point. I've tried to do this with some stupid things, like below. I don't quite get it.  I give an example of how the data look for these variables further below. Please help!

PROC GLM;

Do by Participant#;

 Participant# Readingtime Wordlength Residual 300 1042 6 ? 300 742 4 ? 300 615 4 ? 300 668 5 ? 300 562 3 ? 301 677 6 ? 301 694 4 ? 301 730 4 ? 301 512 5 ? 301 476 3 ? 302 1001 6 ? 302 890 4 ? 302 640 4 ? 302 708 5 ? 302 544 3 ?

Accepted Solutions
Solution
‎03-22-2018 02:41 PM
Super User
Posts: 23,776

## Re: How to write SAS program for residual transformation on self-paced reading data

``````proc reg data=sashelp.class;by sex;
model weight = height age;
output out=want pred = p residual=r;
quit;

proc print data=want;run;``````

All Replies
Super User
Posts: 23,776

## Re: How to write SAS program for residual transformation on self-paced reading data

``````proc reg data=sashelp.class;
model weight = height age;
output out=want pred = p residual=r;
quit;

proc print data=want;run;``````

You need to create an OUTPUT data set, see the code above for a fully worked example.

In general, you should always have a DATA statement so that you know which data set your procedure is using.

Occasional Contributor
Posts: 6

## Re: How to write SAS program for residual transformation on self-paced reading data

I don't understand how this would get the Yhat for the regression equation for each participant and then get the residual for each data point....

Posts: 3,066

## Re: How to write SAS program for residual transformation on self-paced reading data

``by participant;``

into the PROC REG commands.

--
Paige Miller
Solution
‎03-22-2018 02:41 PM
Super User
Posts: 23,776

## Re: How to write SAS program for residual transformation on self-paced reading data

``````proc reg data=sashelp.class;by sex;
model weight = height age;
output out=want pred = p residual=r;
quit;

proc print data=want;run;``````
Posts: 5,543

## Re: How to write SAS program for residual transformation on self-paced reading data

A power model would fit pretty well I bet

``````data temp;
set have;
lWordLength = log(WordLength);
run;

proc mixed data=temp;
class participant;
model lreadingtime = lwordlength / s outpred=outpred residual;
random participant / solution;
ods output SolutionR=SolutionR;
run;``````

make sure you include all the same words for every reader.

PG
Occasional Contributor
Posts: 6

## Re: How to write SAS program for residual transformation on self-paced reading data

Thanks! I'll try this too!

☑ This topic is solved.