BookmarkSubscribeRSS Feed
swbueno
Calcite | Level 5

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:

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
55
56 OPTION PS=62 LS=80;
57 DATA ONE;
58 INPUT X Y;
59 CARDS;
 
NOTE: The data set WORK.ONE has 35 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.02 seconds
 
95 RUN;
 
96 *----ORDINARY LEAST SQUARES REGRESSION---;
97 PROC REG DATA=ONE;
98 MODEL Y = X /SPEC;
99 OUTPUT OUT=OUT1 P=PREDICT R=RESIDUAL;
 
NOTE: The data set WORK.OUT1 has 35 observations and 4 variables.
NOTE: PROCEDIMIENTO REG used (Total process time):
real time 5.57 seconds
cpu time 0.44 seconds
 
100 PROC PLOT DATA=OUT1;
 
101 PLOT RESIDUAL*PREDICT='*' / VREF=0 HPOS=60 VPOS=25;
102 RUN;
 
103 *----VARIANCE OF Y FOR EACH X GROUP----;
104 W = 1/(1.5329-(0.7334*X) +(0.0883*X**2));
_
180
NOTE: The previous statement has been deleted.
ERROR 180-322: Statement is not valid or it is used out of proper order.
105 RUN;
 
106
107 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
119
 
 
How can I gew my variable "W"?
 
Best,
 
Santiago
5 REPLIES 5
ballardw
Super User

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?

 

swbueno
Calcite | Level 5
I want to do the following calculations and assign the results to variable W
 
*----VARIANCE OF Y FOR EACH X GROUP----;
W = 1/(1.5329-(0.7334*X) +(0.0883*X**2));
I get the following error:
 
NOTE: The previous statement has been deleted.
ERROR 180-322: Statement is not valid or it is used out of proper order.
 
RUN;
 
How can I accomplish this?
 
Best,
 
Santiago
 
Reeza
Super User

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
swbueno
Calcite | Level 5
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;

##- Please type your reply above this line. Simple formatting, no
attachments. -##
Reeza
Super User

Ok...that line is in the mdidle of nowhere. It should be in a data step? Or somewhere else?

sas-innovate-2024.png

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.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 1153 views
  • 1 like
  • 3 in conversation