Hi
I wrote this code to Construct a graph of the fitted model versus months. Also to plot the observed number of failures on this graph.
But the code results doesn't show this plot. Can you help with this please
data prog;
input nf month;
datalines;
5 18
3 15
1 14
4 23
0 10
0 5
1 8
0 7
0 12
0 3
1 7
0 2
7 30
0 9
proc genmod data = prog;
model nf= month / dist=Poisson type1 type3 ;
run;
proc logistic data=prog;
model nf=month / aggregate scale=none;
run;
ods graphics on;
proc sort data=prog;by month;run;
proc sgplot data=prog;
title "Problem 3.16.b";
yaxis label="Number of failures";
scatter x=month y=phat / name="points"
legendLabel="number of failures";
series x=month y=nf / name="line"
legendLabel="Predicted number of failures"
lineattrs = GRAPHFIT;
discretelegend "points" "line";
run;
proc genmod plots=all;
model nf = month;
run;
ods graphics off;
You didn't actually create an outputted data set, you need the OUT= portion.
This should get you started then. Your SGPLOT syntax was also wrong so I just simplified it to make it work for now. You can add back the pieces as you get it working. Good Luck.
proc genmod data = prog plots; model nf= month / dist=Poisson type1 type3 ; output out=want predicted=p; run; proc sgplot data=want; yaxis label="Number of failures"; scatter x=month y=p / name="points" ; scatter x=month y=nf / name="line" ; run;
@shahd wrote:
still not working
data prog;
input nf month;
datalines;
5 18
3 15
1 14
4 23
0 10
0 5
1 8
0 7
0 12
0 3
1 7
0 2
7 30
0 9
proc genmod data = prog;
model nf= month / dist=Poisson type1 type3 ;
output predicted=p;
run;
ods graphics on;
proc sort data=prog;by month;run;
proc sgplot data=prog;
yaxis label="Number of failures";
scatter x=month y=p / name="points"
legendLabel="number of failures";
series x=month y=nf / name="line"
legendLabel="Predicted number of failures"
lineattrs = GRAPHFIT;
discretelegend "points" "line";
run;
proc genmod plots=all;
model nf = month;
run;
ods graphics off;
could you please help me to modify it
still not working
data prog;
input nf month;
datalines;
5 18
3 15
1 14
4 23
0 10
0 5
1 8
0 7
0 12
0 3
1 7
0 2
7 30
0 9
proc genmod data = prog;
model nf= month / dist=Poisson type1 type3 ;
output predicted=p;
run;
ods graphics on;
proc sort data=prog;by month;run;
proc sgplot data=prog;
yaxis label="Number of failures";
scatter x=month y=p / name="points"
legendLabel="number of failures";
series x=month y=nf / name="line"
legendLabel="Predicted number of failures"
lineattrs = GRAPHFIT;
discretelegend "points" "line";
run;
proc genmod plots=all;
model nf = month;
run;
ods graphics off;
You didn't actually create an outputted data set, you need the OUT= portion.
This should get you started then. Your SGPLOT syntax was also wrong so I just simplified it to make it work for now. You can add back the pieces as you get it working. Good Luck.
proc genmod data = prog plots; model nf= month / dist=Poisson type1 type3 ; output out=want predicted=p; run; proc sgplot data=want; yaxis label="Number of failures"; scatter x=month y=p / name="points" ; scatter x=month y=nf / name="line" ; run;
@shahd wrote:
still not working
data prog;
input nf month;
datalines;
5 18
3 15
1 14
4 23
0 10
0 5
1 8
0 7
0 12
0 3
1 7
0 2
7 30
0 9
proc genmod data = prog;
model nf= month / dist=Poisson type1 type3 ;
output predicted=p;
run;
ods graphics on;
proc sort data=prog;by month;run;
proc sgplot data=prog;
yaxis label="Number of failures";
scatter x=month y=p / name="points"
legendLabel="number of failures";
series x=month y=nf / name="line"
legendLabel="Predicted number of failures"
lineattrs = GRAPHFIT;
discretelegend "points" "line";
run;
proc genmod plots=all;
model nf = month;
run;
ods graphics off;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: