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;
model Readingtime= Wordlength;
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 | ? |
proc reg data=sashelp.class;
by sex;
model weight = height age;
output out=want pred = p residual=r;
quit;
proc print data=want;run;
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.
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....
You need to add
by participant;
into the PROC REG commands.
proc reg data=sashelp.class;
by sex;
model weight = height age;
output out=want pred = p residual=r;
quit;
proc print data=want;run;
A power model would fit pretty well I bet
data temp;
set have;
lReadingTime = log(readingtime);
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.
Thanks! I'll try this too!
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.