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

## How do I change SAS Linear regression syntax to correct dependent "sleeptime'

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

## Re: How do I change SAS Linear regression syntax to correct dependent "sleeptime'

```
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;

```
15 REPLIES 15
Lapis Lazuli | Level 10

## Re: How do I change SAS Linear regression syntax to correct dependent "sleeptime'

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

Quartz | Level 8

## Re: How do I change SAS Linear regression syntax to correct dependent "sleeptime'

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

Super User

## Re: How do I change SAS Linear regression syntax to correct dependent "sleeptime'

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;
Quartz | Level 8

Thank you Reeza,

Josie

Super User

## Re: How do I change SAS Linear regression syntax to correct dependent "sleeptime'

MODEL dependent = independent;
Super User

## Re: How do I change SAS Linear regression syntax to correct dependent "sleeptime'

```
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;

```
Quartz | Level 8

## Re: How do I change SAS Linear regression syntax to correct dependent "sleeptime'

Dear K. Sharp,

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

Josie

Quartz | Level 8

## Re: How do I change SAS Linear regression syntax to correct dependent "sleeptime'

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

Super User

## Re: How do I change SAS Linear regression syntax to correct dependent "sleeptime'

Pleas include the errors.

Super User

## Re: How do I change SAS Linear regression syntax to correct dependent "sleeptime'

```Did you run PROC FREQ firstly to get that WANT table ?

```
Quartz | Level 8

## Re: How do I change SAS Linear regression syntax to correct dependent "sleeptime'

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

Super User

## Re: How do I change SAS Linear regression syntax to correct dependent "sleeptime'

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.

Super User

## Re: How do I change SAS Linear regression syntax to correct dependent "sleeptime'

http://www.ats.ucla.edu/stat/sas/webbooks/reg/chapter1/sasreg1.htm

Since this is clearly homework you should really do some research.
Quartz | Level 8

## Re: How do I change SAS Linear regression syntax to correct dependent "sleeptime'

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

Discussion stats
• 15 replies
• 1863 views
• 2 likes
• 4 in conversation