DATA Step, Macro, Functions and more

ERROR: Subquery evaluated to more than one row.

Accepted Solution Solved
Reply
Contributor
Posts: 70
Accepted Solution

ERROR: Subquery evaluated to more than one row.

Can you please help: i want to create a new column with type for matching Id. I am getting the error as  ERROR: Subquery evaluated to more than one row

 

 

Proc sql;
alter table dash.fruits
add type char(30) format = $30.;
update dash.fruits as A
set Type = (select b.type from dash.category as b
                  where A.id-b.id);
quit;


Accepted Solutions
Solution
‎04-30-2018 10:31 AM
Contributor
Posts: 36

Re: ERROR: Subquery evaluated to more than one row.

Proc sql;
alter table dash.fruits
add type char(30) format = $30.;
update dash.fruits as A
set Type = (select DISTINCT b.type from dash.category as b
                  where A.id=b.id);
quit;

View solution in original post


All Replies
Trusted Advisor
Posts: 1,848

Re: ERROR: Subquery evaluated to more than one row.

Did you mean: where A.id = b.id); - you have a hyphen instead equal sign.

Contributor
Posts: 70

Re: ERROR: Subquery evaluated to more than one row.

oops typo. i still got the same error

Super User
Super User
Posts: 9,840

Re: ERROR: Subquery evaluated to more than one row.

The error tells you everything you need to know, the subquery:

 (select b.type from dash.category as b
                  where A.id-b.id)

Returned more than one row of data.  Check in dash.category, maybe you have duplicate rows, or more than one merge on id.  This is where showing some test data in the form of a datastep really helps!

Solution
‎04-30-2018 10:31 AM
Contributor
Posts: 36

Re: ERROR: Subquery evaluated to more than one row.

Proc sql;
alter table dash.fruits
add type char(30) format = $30.;
update dash.fruits as A
set Type = (select DISTINCT b.type from dash.category as b
                  where A.id=b.id);
quit;
☑ This topic is solved.

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

Discussion stats
  • 4 replies
  • 249 views
  • 0 likes
  • 4 in conversation