BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
PeteCthulu
Fluorite | Level 6

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

?



1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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

View solution in original post

6 REPLIES 6
Reeza
Super User
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. 

PeteCthulu
Fluorite | Level 6

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....

PaigeMiller
Diamond | Level 26

You need to add

 

by participant;

into the PROC REG commands.

--
Paige Miller
Reeza
Super User

proc
reg data=sashelp.class;
by sex; model weight = height age; output out=want pred = p residual=r; quit; proc print data=want;run;
PGStats
Opal | Level 21

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.

 

PG

sas-innovate-2024.png

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.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 568 views
  • 3 likes
  • 4 in conversation