BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
kngu022
Obsidian | Level 7

Hi everyone;

I tried to make a prediction on data file. and the errors turns up like below. Can you please tell me what wrong is?

DATA add;
	INPUT LogSalary YrMajor @@;YrMajor2=YrMajor*YrMajor;
CARDS;
. 10 
. 20 
;
RUN;
PROC PRINT DATA = add;
RUN;
DATA BOTH;
	SET A2(WHERE=(name^="ROSE,PETE")) add;
RUN;
PROC REG DATA=BOTH;
	MODEL LogSalary = YrMajor YrMajor2/CLB;
	OUTPUT OUT=resid R=resid P=pred LCL=lcl UCL=ucl;
RUN;
QUIT;
PROC PRINT DATA=resid; 
	Var Salary YrMajor YrMajor2 pred lcl ucl;
	WHERE Salary = .;
RUN;
 
 86         PROC REG DATA=BOTH;
 87         MODEL LogSalary = YrMajor YrMajor2/CLB;
 88         OUTPUT OUT=resid R=resid P=pred LCL=lcl UCL=ucl;
 89         RUN;
 
 ERROR: No valid observations are found.
 90         QUIT;
 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

Check the size of the BOTH data set. If your WHERE clause is incorrect, then it will only have the two scoring observations from the ADD data.

 

For example, perhaps the correct WHERE clause needs a space after the comma:

SET A2(WHERE=(name^="ROSE, PETE")) add;

 

View solution in original post

3 REPLIES 3
mkeintz
PROC Star

a


@kngu022 wrote:

Hi everyone;

I tried to make a prediction on data file. and the errors turns up like below. Can you please tell me what wrong is?

DATA add;
	INPUT LogSalary YrMajor @@;YrMajor2=YrMajor*YrMajor;
CARDS;
. 10 
. 20 
;
RUN;
PROC PRINT DATA = add;
RUN;
DATA BOTH;
	SET A2(WHERE=(name^="ROSE,PETE")) add;
RUN;
PROC REG DATA=BOTH;
	MODEL LogSalary = YrMajor YrMajor2/CLB;
	OUTPUT OUT=resid R=resid P=pred LCL=lcl UCL=ucl;
RUN;
QUIT;
PROC PRINT DATA=resid; 
	Var Salary YrMajor YrMajor2 pred lcl ucl;
	WHERE Salary = .;
RUN;
 
 86         PROC REG DATA=BOTH;
 87         MODEL LogSalary = YrMajor YrMajor2/CLB;
 88         OUTPUT OUT=resid R=resid P=pred LCL=lcl UCL=ucl;
 89         RUN;
 
 ERROR: No valid observations are found.
 90         QUIT;
 

 


 

The DATA BOTH step tells SAS to read in all the qualifying observations from A2, followed by the two observations from ADD, resulting in N(A2) + N(ADD) observations.  We can see in your program that ADD only has missing values for LOGSALARY.  Apparently the observations originating in A2 have the same problem, since the PROC REG reports "No valid observations.",  i.e. LOGSALARY is missing for every observation.

 

 

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
kngu022
Obsidian | Level 7

Do you mean that on my data file"add" missing the LogSalary value? How can I fix it when it is what I want to predict with value of YrMajor be 10 and 20?

DATA add;
	INPUT LogSalary YrMajor @@;YrMajor2=YrMajor*YrMajor;
CARDS;
. 10 
. 20 
;
RUN;
Rick_SAS
SAS Super FREQ

Check the size of the BOTH data set. If your WHERE clause is incorrect, then it will only have the two scoring observations from the ADD data.

 

For example, perhaps the correct WHERE clause needs a space after the comma:

SET A2(WHERE=(name^="ROSE, PETE")) add;

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 755 views
  • 2 likes
  • 3 in conversation