BookmarkSubscribeRSS Feed
scb
Obsidian | Level 7 scb
Obsidian | Level 7

I got this error message "Subquery evaluated to more than one row" in the below codes.  Anyone can help? Thanks.

data d1;
input id $ name $;
datalines;
110 Miller
111 Bush
112 Elliot
113 Ryan
;
run;

 

data d2;
Format DATE1 DATE9.;
input id $ date1 DATE9.;
datalines;
110 01JAN2018
111 01FEB2018
112 01MAR2018
114 01APR2018
;
run;

data d3;
Format DATE2 DATE9.;
input id $ date2 DATE9.;
datalines;
110 01JAN2017
111 01FEB2019
112 01MAR2016
113 01APR2019
;
run;

 

PROC SQL;
CREATE TABLE WANT AS SELECT DISTINCT
* FROM D2 WHERE ID IN (SELECT ID FROM D1)
AND DATE1 < (SELECT DATE2 FROM D3);
QUIT;

2 REPLIES 2
Kurt_Bremser
Super User
SELECT DATE2 FROM D3

will result in a list with 4 values, but you may only have one value where you use that subquery. You need to add some kind of summary action to condense D3 into one row.

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 2 replies
  • 296 views
  • 0 likes
  • 2 in conversation