Help using Base SAS procedures

error: variable residual1 not fount

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 8
Accepted Solution

error: variable residual1 not fount

at line 84, there are two errors that variables not found, how to fix this problem?

alos, how to make a proc sgplot order with two scatters, which is first scatter - x=residual1 y=education; second scatter - x=predicted1 y=education;

 

 

 
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
55
56 filename PS4SAS '/folders/myfolders/Econ';
57 /* Establish an extra library named PS4SAS in the Econ folder of My Folders. */
58 data mydata;
59 infile '/folders/myfolders/Econ/nlsextract.raw';
60 input age married education central south indcode occcode union experience tenure hours weeks wage smsa;
61 /* Attach an external file of demographic and workplace variables. */
 
NOTE: The infile '/folders/myfolders/Econ/nlsextract.raw' is:
Filename=/folders/myfolders/Econ/nlsextract.raw,
Owner Name=sasdemo,Group Name=sas,
Access Permission=-rw-rw-r--,
Last Modified=18Oct2016:15:16:14,
File Size (bytes)=40752
 
NOTE: 566 records were read from the infile '/folders/myfolders/Econ/nlsextract.raw'.
The minimum record length was 68.
The maximum record length was 72.
NOTE: SAS went to a new line when INPUT statement reached past the end of a line.
NOTE: The data set WORK.MYDATA has 283 observations and 14 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.02 seconds
 
62 proc means;
 
63 /* Get the mean of the education variable is 12.85159. */
 
NOTE: There were 283 observations read from the data set WORK.MYDATA.
NOTE: PROCEDURE MEANS used (Total process time):
real time 0.10 seconds
cpu time 0.10 seconds
 
64 proc freq;
 
65 tables married;
66 /* For married, there is 36.75% for 0; 63.25% for 1, which is married, and no value was missing for married, total 283
66 ! observations. */
 
NOTE: There were 283 observations read from the data set WORK.MYDATA.
NOTE: PROCEDURE FREQ used (Total process time):
real time 0.05 seconds
cpu time 0.05 seconds
 
67 data mydata; set mydata;
 
68 experience2=experience*experience;
69 /* Get the new variable which is the square of experience variable. */
70 if wage gt 0 then lnwage=log(wage);
71 /* Get the new variable which is the log of the wage variable.*/
 
NOTE: There were 283 observations read from the data set WORK.MYDATA.
NOTE: The data set WORK.MYDATA has 283 observations and 16 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
 
72 data mydata; set mydata;
 
73 if hours ge 25;
74 /* Restrict the average hours of a week greater or equal 25. */
 
NOTE: There were 283 observations read from the data set WORK.MYDATA.
NOTE: The data set WORK.MYDATA has 240 observations and 16 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.02 seconds
 
75 proc sgplot data=mydata;
 
76 scatter x=education y=lnwage;
77 /* Because I use the MacBook SAS university edition, it does not support statement 'proc gplot; plot lnwage*education;'
77 ! therefore, I use sgplot to instead of the 'gplot' statement. */
 
78 proc reg data=mydata;
NOTE: PROCEDURE SGPLOT used (Total process time):
real time 0.27 seconds
cpu time 0.16 seconds
 
NOTE: There were 240 observations read from the data set WORK.MYDATA.
 
79 model lnwage = education;
80 output r=residual1;
81 output r = residual1 p = predicted1;
 
NOTE: The data set WORK.DATA21 has 240 observations and 17 variables.
NOTE: The data set WORK.DATA22 has 240 observations and 18 variables.
NOTE: PROCEDURE REG used (Total process time):
real time 1.77 seconds
cpu time 0.86 seconds
 
82 proc print data=mydata;
 
 
NOTE: There were 240 observations read from the data set WORK.MYDATA.
NOTE: PROCEDURE PRINT used (Total process time):
real time 1.41 seconds
cpu time 1.38 seconds
 
83 proc sgplot data=mydata;
 
84 scatter x=residual1 y=education;
ERROR: Variable RESIDUAL1 not found.
85 scatter x=predicted1 y=education;
ERROR: Variable PREDICTED1 not found.
86 run;
 
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SGPLOT used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
 
87
88 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
100

Accepted Solutions
Solution
‎10-18-2016 10:11 PM
Trusted Advisor
Posts: 1,384

Re: error: variable residual1 not fount

[ Edited ]

The variables residual1 , prdeicted1 are created by proc reg (log line 78) with input mydata, output data21 and data22;

 

The ERROR mesage relates to proc sgplot (log line 83) with input mydata.

 

To fix the error choose one of the above output datasets (dtata21 or data22).

 

View solution in original post


All Replies
Solution
‎10-18-2016 10:11 PM
Trusted Advisor
Posts: 1,384

Re: error: variable residual1 not fount

[ Edited ]

The variables residual1 , prdeicted1 are created by proc reg (log line 78) with input mydata, output data21 and data22;

 

The ERROR mesage relates to proc sgplot (log line 83) with input mydata.

 

To fix the error choose one of the above output datasets (dtata21 or data22).

 

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 192 views
  • 0 likes
  • 2 in conversation