| Date: | Tue, 19 Oct 2010 16:59:32 -0500 |
| Reply-To: | Craig Johnson <cjohns38@GMAIL.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Craig Johnson <cjohns38@GMAIL.COM> |
| Subject: | Re: PROC SQL Update Question |
|
| In-Reply-To: | <AANLkTi=JPR7KS+t7mLpJWrdEqdXc7+ODBgAbDFXAN9MZ@mail.gmail.com> |
| Content-Type: | text/plain; charset=ISO-8859-1 |
|---|
Hi Joe,
Thanks for the quick reply and the detailed response. These sort of
responses make it helpful for us budding SAS users.
It looks like my big error was putting the group by before the where (I
think) and not including a check to make sure that the ID exists. I looked
at SAS's example and kind of blew past but but you defiantly only want to
update if they exist. Below is the final code I used. Note that I used a
little different method for checking for the ID.
Thanks again for the help!
proc sql;
UPDATE CALIBRATION_TRANS AS A
SET Max_Trial= ( ( SELECT MAX(CalibrationBlock_Sample)
FROM Split_char_calibrationblock AS B
WHERE A.SUBJECT=B.SUBJECT
Group by Subject))
WHERE A.Subject In(Select Subject From Split_char_calibrationblock);
QUIT;
|