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

Hi all, I am trying to left join one table with two tables to get multiple variables. I wrote some code but its showing me an error. Any help is appreciated.

 proc sql;
 437         create table _02a_nl as
 438         select distinct a.*,b.labcomponent,b.TestResultCleaned,c.labcomponent,c.TestResultCleaned,neutrophil,lymphocyte
 439         ,b.TestDate as neu_date format mmddyy10. ,c.TestDate as lymp_date format mmddyy10.,
 440         case
 441         when b.labcomponent = 'Neutrophil Count (absolute)' and b.TestResultCleaned ne . then b.TestResultCleaned
 442         else .
 443         end as neutrophil,
 444         case
 445         when c.labcomponent = 'Lymphocyte Count Absolute' and c.TestResultCleaned ne . then c.TestResultCleaned
 446         else .
 447         end as lymphocyte
 448         from _02a_insurance as a
 449         left join dfi_panc.lab as b
 450         on a.PatientID = b.PatientID
 451         left join dfi_panc.lab as c
 452         on a.PatientID=c.PatientID
 453         and ((a.index_date -30) le b.TestDate le (a.index_date)) AND (b.labcomponent = ('Neutrophil Count (absolute)')
 454         AND ((a.index_date -30) le c.TestDate le (a.index_date)) AND (c.labcomponent =('Lymphocyte Count Absolute'))
 455        order by a.PatientID,b.TestDate,c.TestDate;
             _____
             79
 ERROR 79-322: Expecting a ).
 
1 ACCEPTED SOLUTION

Accepted Solutions
AhmedAl_Attar
Rhodochrosite | Level 12

Hi @manya92

 

The error is from these two lines

and ........ AND (b.labcomponent = ('Neutrophil Count (absolute)')  /* This could be missing a closing )! */
AND ........ AND (c.labcomponent =('Lymphocyte Count Absolute')) /* This could be using the wrong syntax? */

I think you need to revise either or both

 

Hope this helps,

Ahmed

View solution in original post

3 REPLIES 3
AhmedAl_Attar
Rhodochrosite | Level 12

Hi @manya92

 

The error is from these two lines

and ........ AND (b.labcomponent = ('Neutrophil Count (absolute)')  /* This could be missing a closing )! */
AND ........ AND (c.labcomponent =('Lymphocyte Count Absolute')) /* This could be using the wrong syntax? */

I think you need to revise either or both

 

Hope this helps,

Ahmed

ccaulkins9
Pyrite | Level 9
Touche, the Flash!
e-SAS regards,

Kurt_Bremser
Super User

In the Enhanced Editor, place the cursor after the last closing bracket. The Editor will highlight this bracket and the one opening bracket it sees as corresponding. This will give you a clue where a closing bracket is missing.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

Discussion stats
  • 3 replies
  • 923 views
  • 2 likes
  • 4 in conversation