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;

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;

 

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
Ksharp
Super User

There are too many ties in table. You need FREQ statement.




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
;
run;
proc freq data=case2;
table sleeptime*lifesatisfaction /out=want list;
run;
proc reg data=want;
model lifesatisfaction = sleeptime / p r;
freq count;
output out=case2Out residual=resid1;
run;
quit;



View solution in original post

15 REPLIES 15
Norman21
Lapis Lazuli | Level 10

I'm not sure what you are asking about SAS code, but I do have a question.

 

"A researcher hypothesizes... " implies there was a pre-specified hypothesis, which should include a description of the statistical test to be used. This information would have been required to determine the sample size when designing the study. Can you provide the name of the test?

Norman.
SAS 9.4 (TS1M6) X64_10PRO WIN 10.0.17763 Workstation

jmoseley
Quartz | Level 8

Hi Norman 21,

 

We were provided with the summary and the table. The heading provided was Linear Regression. We had to use the information provided to answer various questions such as 1) What is the criterion variable; 2) What is the predictor variable, etc. All ther questions were based on Using SAS to conduct simple regression analysis.

 

Josie 

Reeza
Super User
Please post your question in the body. The subject line is like an email subject line - intended as a brief summary.

You may want to read a regression tutorial - I suggest the UCLA tutorials.

You should modify your MODEL starement.
The format is:

DEPENDENT = INDEPENDENT LIST;
Ksharp
Super User

There are too many ties in table. You need FREQ statement.




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
;
run;
proc freq data=case2;
table sleeptime*lifesatisfaction /out=want list;
run;
proc reg data=want;
model lifesatisfaction = sleeptime / p r;
freq count;
output out=case2Out residual=resid1;
run;
quit;



jmoseley
Quartz | Level 8

Dear K. Sharp,

 

Once again thank you very much for your assistance, I do appreciate your help!

 

Josie

jmoseley
Quartz | Level 8

Hello K Sharp,

 

Unfortunately the output was not successful. I received an error message which states;

NOTE.: The SAS System stopped processing this step because of errors

199 proc reg data=want;
200 model lifesatisfaction = sleeptime / p r;
201 freq count;
202 output out=case2Out residual=resid1;
203 run;
204 quit;

 

Josie

Ksharp
Super User
Did you run PROC FREQ firstly to get that WANT table ?

jmoseley
Quartz | Level 8

Hi K sharp,

 

I ran the syntax that you changed and posted, namely,

 

ata 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
;
run;
proc freq data=case2;
table sleeptime*lifesatisfaction /out=want list;
run;
proc reg data=want;
model lifesatisfaction = sleeptime / p r;
freq count;
output out=case2Out residual=resid1;
run;
quit;

Thanks K Sharp,

Josie

 

Reeza
Super User

You're missing a d at the start of your code (data vs ata) but other than that the code runs perfectly fine for me.

jmoseley
Quartz | Level 8

Hi Reeza,

 

The Reason why I am requesting assistance is because I have done extensive reading and research but somehow am missing one small thing that may be hampering my success. I am not expecting anyone to do my homework for me.

 

Josie

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

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
  • 15 replies
  • 1863 views
  • 2 likes
  • 4 in conversation