Having Issues running the SQL Code below. Please tell me what I am doing wrong.

Reply
New Contributor
Posts: 3

Having Issues running the SQL Code below. Please tell me what I am doing wrong.

I am having trouble running the SAS Sql program below.  However when I run the program below in a postgres database it works fine.  I continue to get the following error in SAS.  Please help!!!!

proc sql;

connect to odbc as mydb (datasrc=abc user=def password=ghiSAS) ;

     create table two as

select row_to_json(t)

from (

   select

     (

SELECT array_to_json(array_agg(row_to_json(d)))

from (

                select    employee_skey as employee_skey,

                BUYER_ID as user_number,

                EMPLOYEE_FULL_NAME as full_name,

                EMPLOYEE_EMAIL as email

                FROM employee) d

) as buyer_users

) t

;

disconnect from mydb;

Program below works fine when executing in Postgres Database

select row_to_json(t)

from (

   select

     (

SELECT array_to_json(array_agg(row_to_json(d)))

from (

                select    employee_skey as employee_skey,

                BUYER_ID as user_number,

                EMPLOYEE_FULL_NAME as full_name,

                EMPLOYEE_EMAIL as email

                FROM employee) d

) as buyer_users

) t

ERROR i am receiving in SAS...

23         GOPTIONS ACCESSIBLE;

24         proc sql;

25         connect to odbc as mydb (datasrc=abc user=def password=ghiSAS) ;

26              create table two as

27         select row_to_json(t)

28         from (

29            select

30              (

31         SELECT array_to_json(array_agg(row_to_json(d)))

32         from (

33                         select    employee_skey as employee_skey,

34                         BUYER_ID as user_number,

35                         EMPLOYEE_FULL_NAME as full_name,

36                         EMPLOYEE_EMAIL as email

37                         FROM employee) d

38         ) as buyer_users

39         ) t

           _

           22

           76

ERROR 22-322: Syntax error, expecting one of the following: a quoted string, ',', AS, FORMAT, FROM, INFORMAT, INTO, LABEL, LEN,

              LENGTH, TRANSCODE. 

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

40         ;

NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.

41         disconnect from mydb;

NOTE: Statement not executed due to NOEXEC option.

42        

43         GOPTIONS NOACCESSIBLE;

44         %LET _CLIENTTASKLABEL=;

45         %LET _CLIENTPROJECTPATH=;

46         %LET _CLIENTPROJECTNAME=;

47         %LET _SASPROGRAMFILE=;

Ask a Question
Discussion stats
  • 0 replies
  • 138 views
  • 0 likes
  • 1 in conversation