good morning,
Either sql or data step is fine with me.
I am trying to update the obligating_doc_no rom pips_data with obligating_document_no from B7600 table. I get an error indicating that "
ERROR: Subquery evaluated to more than one row.
NOTE: Correlation values are: IPAC='89000001' ." I used the code below.
proc sql;
update pips_data p
set obligating_doc_no =
(select obligating_doc_no
from tableB b
where p.ipac = b.ipac
)
where obligating_doc_no in
(select obligating_doc_no
from tableB
);
quit;
That is how the data is. No date.
It is pretty easy to see that you have duplicate values for OBLIGATING_DOC_NO with the same IPAC value. This is from the first 3 data lines of your B7600s.csv, which I have to assume is related to your TableB.
IPAC OBLIGATING_DOC_NO TAS ACCOUNTING 89000001 89233119SNA000165 08920192020 0251000 01278.2019.01.100260.2510 89000001 89233119SNA000165 089 X0251000 01250.2019.01.100260.2510 89000001 89233119SNA000165 08920192020 0240000 70052.2019.60.300602.2510
Subqueries used like the highlighted need to return a single value
proc sql; update pips_data p set obligating_doc_no = (select obligating_doc_no from tableB b where p.ipac = b.ipac )
like the error message says. So you need an additional filter on your data to ensure you get one and only one value of the variable from the subquery for the value of Ipac.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.