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

data case2;
input sleeptime $ lifesatisfaction;
datalines
st 7.5
st 8.3
st 9.5
st 8.5
st 6.0
st 8.0
st 7.3
st 7.0
st 8.0
st 6.5
ls 23
ls 19
ls 16
ls 20
ls 40
ls 22
ls 30
ls 25
ls 30
ls 36
;
proc reg data case2;
model lifesatisfaction = sleeptime;
run;
quit;

 

 

A researcher hypothesizes that undergraduate students who are satisfied with their lives will sleep less than those who are not satisfied. To test this hypothesis, she selects a sample of undergraduate students and asks them to maintain a “sleep log” (Drowsy, 1977), keeping track of the number of hours they sleep during each 24-hour period. These logs are maintained for two weeks. At the end of the two-week period, each participant completes the Satisfaction with Life Scale (Giggle & Smirk, 1969), a reliable, validated measure of general satisfaction with life.

 

These are the data the researcher obtained:

 

Participant

Mean Hours of Sleep

SWL Score

01

7.5

23

02

8.3

19

03

9.5

16

04

8.5

20

05

6.0

40

06

8.0

22

07

7.3

30

08

7.0

25

09

8.0

30

10

6.5

36

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Just a few syntax fixes:

 

data case2;
input sleeptime lifesatisfaction;
datalines;
7.5 23
8.3 19
9.5 16
8.5 20
6.0 40
8.0 22
7.3 30
7.0 25
8.0 30
6.5 36
7.5 23
8.3 19
9.5 16
8.5 20
6.0 40
8.0 22
7.3 30
7.0 25
8.0 30
6.5 36
7.5 23
8.3 19
9.5 16
8.5 20
6.0 40
8.0 22
7.3 30
7.0 25
8.0 30
6.5 36
;

proc reg data=case2;
model lifesatisfaction = sleeptime / p r;
output out=case2Out residual=resid1;
run;
quit;

proc univariate plot data=case2Out normal;
var resid1;
run;
PG

View solution in original post

10 REPLIES 10
jmoseley
Quartz | Level 8

Reeza, thank you for your previous info you provided with regard to SAS linear regression code. I attempted it but was unsuccessful. Error messages occurred.

Here are my SAS codes.

 

data case2;
input sleeptime $ lifesatisfaction;
datalines;
7.5 23
8.3 19
9.5 16
8.5 20
6.0 40
8.0 22
7.3 30
7.0 25
8.0 30
6.5 36
7.5 23
8.3 19
9.5 16
8.5 20
6.0 40
8.0 22
7.3 30
7.0 25
8.0 30
6.5 36
7.5 23
8.3 19
9.5 16
8.5 20
6.0 40
8.0 22
7.3 30
7.0 25
8.0 30
6.5 36
;
proc reg data case2;
model lifesatisfaction = sleeptime / p r;
plot predicted * sleeptime = 'p' lifesatisfaction * sleeptime = '*'/ overlay;
plot residual.* predicted.;
output sleeptime $ lifesatisfaction residual=resid1;
proc univariate plot data=case2;
var resid1;
run;

A researcher hypothesizes that undergraduate students who are satisfied with their lives will sleep less than those who are not satisfied. To test this hypothesis, she selects a sample of undergraduate students and asks them to maintain a “sleep log” (Drowsy, 1977), keeping track of the number of hours they sleep during each 24-hour period. These logs are maintained for two weeks. At the end of the two-week period, each participant completes the Satisfaction with Life Scale (Giggle & Smirk, 1969), a reliable, validated measure of general satisfaction with life.

 

These are the data the researcher obtained:

 

Participant

Mean Hours of Sleep

SWL Score

01

7.5

23

02

8.3

19

03

9.5

16

04

8.5

20

05

6.0

40

06

8.0

22

07

7.3

30

08

7.0

25

09

8.0

30

10

6.5

36

 

PGStats
Opal | Level 21

If you enter the data the researcher obtained, in the format the researcher provided, i.e. one observation per subject, you will be able to perform your homework regression. 

PG
jmoseley
Quartz | Level 8

I tried that but I am still getting many errors.

data case2;
input sleeptime $ lifesatisfaction;
datalines;
7.5 23
8.3 19
9.5 16
8.5 20
6.0 40
8.0 22
7.3 30
7.0 25
8.0 30
6.5 36
7.5 23
8.3 19
9.5 16
8.5 20
6.0 40
8.0 22
7.3 30
7.0 25
8.0 30
6.5 36
7.5 23
8.3 19
9.5 16
8.5 20
6.0 40
8.0 22
7.3 30
7.0 25
8.0 30
6.5 36
;
proc reg data case2;
model lifesatisfaction = sleeptime / p r;
plot predicted * sleeptime = 'p' lifesatisfaction * sleeptime = '*'/ overlay;
plot residual.* predicted.;
output sleeptime $ lifesatisfaction residual=resid1;
proc univariate plot data=case2;
var resid1;
run;
quit;

PGStats
Opal | Level 21

Just a few syntax fixes:

 

data case2;
input sleeptime lifesatisfaction;
datalines;
7.5 23
8.3 19
9.5 16
8.5 20
6.0 40
8.0 22
7.3 30
7.0 25
8.0 30
6.5 36
7.5 23
8.3 19
9.5 16
8.5 20
6.0 40
8.0 22
7.3 30
7.0 25
8.0 30
6.5 36
7.5 23
8.3 19
9.5 16
8.5 20
6.0 40
8.0 22
7.3 30
7.0 25
8.0 30
6.5 36
;

proc reg data=case2;
model lifesatisfaction = sleeptime / p r;
output out=case2Out residual=resid1;
run;
quit;

proc univariate plot data=case2Out normal;
var resid1;
run;
PG
jmoseley
Quartz | Level 8
Thank you so very much PG stats. I see now where I made syntax errors. I do appreciate you help very much. Josie
jmoseley
Quartz | Level 8

PG STATS,

 

Thank you very much for your assistance with the SAS syntax of the Satisfaction with life problem.

 Could you tell me where I can get any information on analyzing the output of the SAS  problem you assisted me with.

 

I realise that in order to know how to do the problems and to prepare for my final exams, I will need to know how to  answer the specific answers. I have been able to answer quite a few questions regarding the null hypothesis, regression equation etc,. Some questions I am struggling to answer are:

1. 

  1. What is “the predicted mean hours of sleep” for someone with an SWL score of 32? 
  2. What are “the predicted mean hours of sleep” and “the residual” for research participant #7? 
  3. What is the value for regression of sums-of-squares (SSreg)?
  4. What is the value for the standard error of estimate? 
  5. What are the values for coefficients of determination and alienation? 
  6. We would like to test if the proportion of the variance is significantly accounted for by the predictor. What is the null hypothesis? What is the statistic we use to test this hypothesis? What is your decision (reject or fail to reject)
  7. We would also like to test if the slope differs significant from 0. What is the null hypothesis? What is the statistic we use to test this hypothesis? 
  8. Regarding outlier diagnosis, which participants are more likely potential outliers?
PGStats
Opal | Level 21

Your textbook will give much better answers to these questions than I could, even if I had the time. Good luck with your studies.

PG
Reeza
Super User
Post your log. What errors are you receiving? Your 'question' looks strongly like homework or training so I don't like to answer those questions unless they are very specific. This is my opinion and guidelines only, not the community.
jmoseley
Quartz | Level 8

This is the message in the log after I posted my SAS code.

 

 

data case2;
2 input sleeptime $ lifesatisfaction;
3 datalines;

NOTE: The data set WORK.CASE2 has 30 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.14 seconds
cpu time 0.01 seconds


34 ;
35 proc reg data case2;
-----
73
NOTE: Writing HTML Body file: sashtml.htm
ERROR 73-322: Expecting an =.
36 model lifestatisfaction = sleeptime;
ERROR: Variable LIFESTATISFACTION not found.
ERROR: Variable sleeptime in list does not match type prescribed for this list.
NOTE: The previous statement has been deleted.
37 run;

WARNING: No variables specified for an SSCP matrix. Execution terminating.
NOTE: PROCEDURE REG used (Total process time):
real time 2.09 seconds
cpu time 0.28 seconds


38 quit;

 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 10 replies
  • 2267 views
  • 3 likes
  • 3 in conversation