BookmarkSubscribeRSS Feed
Statsconsultancy
Fluorite | Level 6
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.
1 REPLY 1
ArtC
Rhodochrosite | Level 12
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]

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!

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
  • 1 reply
  • 1089 views
  • 0 likes
  • 2 in conversation