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 |
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;
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?
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
Thank you Reeza,
Josie
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;
Dear K. Sharp,
Once again thank you very much for your assistance, I do appreciate your help!
Josie
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
Pleas include the errors.
Did you run PROC FREQ firstly to get that WANT table ?
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
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.
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
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.