I have run the following code:
OPTION PS=62 LS=80;
DATA ONE;
INPUT X Y;
CARDS;
1.15 0.99
1.90 0.98
3.00 2.60
3.00 2.67
3.00 2.66
3.00 2.78
3.00 2.80
5.34 5.92
5.38 5.35
5.40 4.33
5.40 4.89
5.45 5.21
7.70 7.68
7.80 9.81
7.81 6.52
7.85 9.71
7.87 9.82
7.91 9.81
7.94 8.50
9.03 9.47
9.07 11.45
9.11 12.14
9.14 11.50
9.16 10.65
9.37 10.64
10.17 9.78
10.18 12.39
10.22 11.03
10.22 8.00
10.22 11.90
10.18 8.68
10.50 7.25
10.23 13.46
10.03 10.19
10.23 9.93
RUN;
*----ORDINARY LEAST SQUARES REGRESSION---;
PROC REG DATA=ONE;
MODEL Y = X /SPEC;
OUTPUT OUT=OUT1 P=PREDICT R=RESIDUAL;
PROC PLOT DATA=OUT1;
PLOT RESIDUAL*PREDICT='*' / VREF=0 HPOS=60 VPOS=25;
RUN;
*----VARIANCE OF Y FOR EACH X GROUP----;
W = 1/(1.5329-(0.7334*X) +(0.0883*X**2));
RUN;
And get the following error in the log:
You will have to be more explicit about what you are wanting.
The code comment is either misleading or false:
*----VARIANCE OF Y FOR EACH X GROUP----;
since many of your x values are not repeated the size of an X group would be 1 for many values and the variance will always be 0: No variability=> no variance. You maybe want to look at another procedure such as Proc Means to get the desired variance.
Also in
W = 1/(1.5329-(0.7334*X) +(0.0883*X**2));
Where do those constants come from?
Formulas like that would have to be an a data step some where. Maybe you intended to use another data step on the output of the predicitons from Proc Reg?
You need to show your full code and log.
Although the log is showing that line as an error, we can't say why.
You're possibly missing something on the previous line - a semicolon?
The line on it's own is fine:
1 data test;
2 x=24;
3
4
5 W = 1/(1.5329-(0.7334*X) +(0.0883*X**2));
6 run;
NOTE: The data set WORK.TEST has 1 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.36 seconds
cpu time 0.00 seconds
Ok...that line is in the mdidle of nowhere. It should be in a data step? Or somewhere else?
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.