Help using Base SAS procedures

PROC REG (Getting the right results)

Reply
Occasional Contributor
Posts: 16

PROC REG (Getting the right results)

I have the following data
data no_of_alerts;
Input doctor alerts error;
cards;
1 1 1
2 1 0
3 1 1
4 1 1
5 1 1
1 2 1
2 2 1
3 2 1
4 2 0
5 2 1
1 3 1
2 3 0
3 3 1
4 3 0
5 3 1
1 4 1
2 4 0
3 4 1
4 4 0
5 4 0
;
Suppose I want to run linear regression model alerts = mean_error, where now Mean_error is the mean error of the alerts. As an example ,for alerts = 1 the mean is 0.8 (1+0+1+1+1)/5). Thus my points will be (1,0.8), (2, 0.8), (3, 0.6) and (4,0.4). Can someone help.

If I use proc reg; Model = alerts = error; run. I get the wrong results.
Valued Guide
Posts: 634

Re: PROC REG (Getting the right results)

Posted in reply to Statsconsultancy
I only think that I understand the what and certainly not the why, but here is a first pass:

[pre]
data no_of_alerts;
Input doctor alerts error;
cards;
1 1 1
2 1 0
3 1 1
4 1 1
5 1 1
1 2 1
2 2 1
3 2 1
4 2 0
5 2 1
1 3 1
2 3 0
3 3 1
4 3 0
5 3 1
1 4 1
2 4 0
3 4 1
4 4 0
5 4 0
run;

title1 'mean Errors for each alert';
proc means data=no_of_alerts nway;
class alerts;
var error;
output out=meanerr(keep=alerts meanerror)
mean=meanerror;
run;

title1 'Alerts using Mean Errors';
proc reg data=meanerr;
model alerts=meanerror;
run;
[/pre]
Ask a Question
Discussion stats
  • 1 reply
  • 100 views
  • 0 likes
  • 2 in conversation