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

Hello

 

I cant seem to figure out my error in the tables I am creating, it says expecting as, like or (

 

 

 

Proc sql inobs=max outobs=max;
 Create table work.mbr_program;
 select distinct L.mbr_id,
 L.ENRL_DT,
 L.MBR_PGM_STS_TYP_ID,
 L.MBR_PGM_STS_RSN_TYP_ID
 From input.mbr_pgm L,
 STG_HSR.MBR_PGM P
 where L.ENRL_DT is not null
            and P.MBR_PGM_STS_RSN_TYP_ID ='81'
             and P.MBR_PGM_STS_TYP_ID ='05';
             quit;
            
     Proc sql inobs=max outobs=max;
        Create table work.mbr_program_wellness;
        select distinct a.*,
        L.mbr_pgm_id  as MP_MBR_PGM_ID,
        L.ENRL_DT, 
        L.END_DT,
        L.MBR_PGM_STS_TYP_ID,
        L.MBR_PGM_STS_RSN_TYP_ID
        From sasdata.five a,
             input.mbr_pgm L
        where L.mbr_id = a.mbr_id
            and L.END_DT >= (today() - 30)
            and L.MBR_PGM_STS_RSN_TYP_ID ='81'
             and L.MBR_PGM_STS_TYP_ID ='05'
             and a.AYB_MODALITY = '2_coach';
             quit;       

 

 

 

Proc sql inobs=max outobs=max;
373                Create table work.mbr_program_wellness;
                                                         _
                                                         22
                                                         76
ERROR 22-322: Syntax error, expecting one of the following: (, AS, LIKE. 

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

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

The whole create table statement must not be broken by a semicolon; Everything (create table, select from, where etc) needs to be one statement:

proc sql inobs=max outobs=max;
create table work.mbr_program_wellness as
select
  distinct a.*,
  L.mbr_pgm_id  as MP_MBR_PGM_ID,
  L.ENRL_DT, 
  L.END_DT,
  L.MBR_PGM_STS_TYP_ID,
  L.MBR_PGM_STS_RSN_TYP_ID
from
  sasdata.five a,
  input.mbr_pgm L
where
  L.mbr_id = a.mbr_id
  and L.END_DT >= (today() - 30)
  and L.MBR_PGM_STS_RSN_TYP_ID ='81'
  and L.MBR_PGM_STS_TYP_ID ='05'
  and a.AYB_MODALITY = '2_coach'
;
quit;

Do the same in your first SQL.

View solution in original post

4 REPLIES 4
Kurt_Bremser
Super User

The whole create table statement must not be broken by a semicolon; Everything (create table, select from, where etc) needs to be one statement:

proc sql inobs=max outobs=max;
create table work.mbr_program_wellness as
select
  distinct a.*,
  L.mbr_pgm_id  as MP_MBR_PGM_ID,
  L.ENRL_DT, 
  L.END_DT,
  L.MBR_PGM_STS_TYP_ID,
  L.MBR_PGM_STS_RSN_TYP_ID
from
  sasdata.five a,
  input.mbr_pgm L
where
  L.mbr_id = a.mbr_id
  and L.END_DT >= (today() - 30)
  and L.MBR_PGM_STS_RSN_TYP_ID ='81'
  and L.MBR_PGM_STS_TYP_ID ='05'
  and a.AYB_MODALITY = '2_coach'
;
quit;

Do the same in your first SQL.

Rsadiq
Calcite | Level 5

Okay thank you I will try it out!

Kurt_Bremser
Super User

Actually, this (in red)

ERROR 22-322: Syntax error, expecting one of the following: (, AS, LIKE.

is the significant part of the ERROR message. The keyword "as" is what connects the create table with the rest.

moorsd
Obsidian | Level 7

What happens if you add an 'AS' on the FROM statement. See below:

 

Do you still get the ERROR?

 

proc sql inobs=max outobs=max;
create table work.mbr_program_wellness as
select
  distinct a.*,
  L.mbr_pgm_id  as MP_MBR_PGM_ID,
  L.ENRL_DT, 
  L.END_DT,
  L.MBR_PGM_STS_TYP_ID,
  L.MBR_PGM_STS_RSN_TYP_ID
from
  sasdata.five AS a,
  input.mbr_pgm AS L
where
  L.mbr_id = a.mbr_id
  and L.END_DT >= (today() - 30)
  and L.MBR_PGM_STS_RSN_TYP_ID ='81'
  and L.MBR_PGM_STS_TYP_ID ='05'
  and a.AYB_MODALITY = '2_coach'
;
quit;

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 4 replies
  • 31420 views
  • 1 like
  • 3 in conversation