BookmarkSubscribeRSS Feed
bhca60
Quartz | Level 8

Not sure what this means. I'm trying to get list of IDs but I get an error.


23         proc sql;
24         create table data
25         as select
26         a.*,
27         b.Type,
28         b.ID
29         from A inner join B
30         on a.npi=b.id
31         where Type in TIN and
                                   ___
                                   79
                                   76
ERROR 79-322: Expecting a SELECT.

ERROR 76-322: Syntax error, statement will be ignored.

32         ID in ('111111111' '222222222' '333333333' '66666666' '77777777');
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
34         quit;
9 REPLIES 9
Reeza
Super User

SHould this be your query?

 

 

         proc sql;
         create table data
         as select
         a.*,
         b.Type,
         b.ID
         from A inner join B
         on a.npi=b.provnpi
         where Type = TIN
         and b.ID in ('111111111' '222222222' '333333333' '66666666' '77777777');                               

 

Note that you may want to provide alias on your variables in the WHERE clause, ie b.ID or a.ID as appropriate. 

 

 

bhca60
Quartz | Level 8

i changed it. 

bhca60
Quartz | Level 8

its an ID number - its a character

ballardw
Super User

The IN operator requires a list of values appearing inside ( ), even for a single value in general.

Where you use "Type in TIN" and there is no (  then Proc SQL is expecting a sub-query starting with SELECT to provide the list.

 

Run these two steps and see if the second comes closer to what you expected given the small size of SASHELP.CLASS.

Proc sql;
   select *
   from sashelp.class
   where sex in F
   ;
quit;

Proc sql;
   select *
   from sashelp.class
   where sex in ('F')
   ;
quit;



bhca60
Quartz | Level 8
I tried = sign and it gave an error to that as well which is why I did the IN operator.
pink_poodle
Barite | Level 11
proc sql;
        CREATE TABLE data AS
         SELECT a.*, b.Type, b.ID
         FROM A inner join B
         ON a.npi=b.provnpi
         WHERE Type in (select TIN from a) /* not sure a or b */
         and b.ID in ('111111111' '222222222' '333333333' '66666666' '77777777')
;   
quit;      
Reeza
Super User

Where is TIN coming from?

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!
SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 9 replies
  • 1697 views
  • 4 likes
  • 5 in conversation