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

Hi,

I m trying to concatenate few strings so that the output looks like following. 

ACT_D:20230402

The syntax I was using is 'ACT_D:'||PUT(Complete_Full_Date, yymmddn8.) as REF4,

but it gives the error as 

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

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

 

 

The complete code is as following: 

proc sql;
create table FORMATED_COMP AS
SELECT Order_Number AS Invoice,
&Paydate as Pay_Date ,
EMPLOYEE_PEIN as Employee ,
1 as Item ,
'COSBI' as REASON_CODE ,
Channel_Level_2 as LC,
ISSUED_FULL_DATE AS SALE_DATE format date9.,
'' as ESN ,
'' AS TEXT1 ,
'' AS TEXT2 ,
'' AS POSSKU ,
'LOB:DSL' AS REF1 ,
Product_Description AS REF2,
CASE WHEN PRODUCT_CODE IN (
'1-3K1XCP0',
'1-3K1XCOB',
'1-J6FZOO-C17',
'1-J6G02L-C17',
'1-J6HCI9-C17',
'1-J6HCI9-C17LOB',
'1-J6HCKD-C17',
'1-J6FZWE-C17') THEN 'Internet 5, 5 Plus or' ELSE 'Internet 100+'
END as REF3,
'ACT_D:'||PUT(Complete_Full_Date, yymmddn8.) as REF4,
'BRS Base Commission' as REF5 ,
'' as REF6,
'' as REF7,
'' as REF8,
1 AS Volume ,
'' as Base_package_Price ,
Commission AS Amount,
'' as Amount2 ,
Dealer_NM AS Corp_store_name,
Province_Code as Region_Name,
'' as Employee_Name ,
'SB Internet Commission' as DESCRIPTION,
EMP_TITLE_EN_DESC AS JOB_NAME,
case when EMP_TITLE_EN_DESC = 'Sales Consultant - BRS Retail' then 'SP' else 'NSP' end as JGRP,
COMPLETE_FULL_DATE AS Activation_Dt format date9.
'' as Paid_sts,
'' as Status
FROM Employee_info t1 ;
RUN;

 

Will appreciate the help. Thanks .

 

I am using SAS EG. 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Any time you have an error or other message in the Log that you want help with then copy the submitted code for the procedure or data step and all of the associated messages. Then on the forum open a text box and paste the text.

The text box is important because it preserves formatting of diagnostic characters that SAS often provides AND then we can make corrections/suggestions by copying text, editing and pasting the modified text for you to use.

 

An example, different error but same cause: missing comma between select elements. Even with a different error we can tell where in code the issue is because we don't have to parse lots of stuff.  We can see it is likely around the "ABC:"

466  proc sql;
467     create table junk as
468     select sex
469     "ABC:"||put(weight,f5.1) as ref
              --
              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.

470     from sashelp.class
471     ;
472  quit;

View solution in original post

3 REPLIES 3
Cynthia_sas
SAS Super FREQ

Hi: My guess is that there's some other error in your code. Without seeing your full log, however, it's impossible to guess where the error might be. If I had to take a guess, I would expect that the previous
&paydate as Pay_Date,
is probably the place where the error messages start. But that is just a guess. You don't show what is the value for the macro variable &paydate, however, I can generate a nice error like this without doing a concatenate and using SASHELP.CLASS:

Cynthia_sas_0-1681943250494.png


But I can fix the issue if I tell PROC SQL to treat the macro variable as a date constant:

Cynthia_sas_1-1681943274474.png

Also note that PROC SQL ends correctly with a QUIT; not with a RUN; You should be seeing this message in the log:

Cynthia_sas_2-1681943357551.png

 

For more help, please explain your use of Macro variables post all of your code and some sample data for people to use. Without data, we don't know whether your date values are character or numeric or what the macro variables contain.

 

Cynthia



Cynthia

Tom
Super User Tom
Super User

Reformat your code so it is easier for Humans to scan and the missing comma before   COMPLETE_FULL_DATE AS Activation_Dt format date9.

in your SELECT clause will be more obvious.

create table FORMATED_COMP AS
  SELECT Order_Number AS Invoice
  , &Paydate as Pay_Date 
  , EMPLOYEE_PEIN as Employee 
  ....
  , case when EMP_TITLE_EN_DESC = 'Sales Consultant - BRS Retail' then 'SP' else 'NSP' end as JGRP
  , COMPLETE_FULL_DATE AS Activation_Dt format date9.
  , ' ' as Paid_sts
  , ' ' as Status
  FROM Employee_info t1 
;

 

ballardw
Super User

Any time you have an error or other message in the Log that you want help with then copy the submitted code for the procedure or data step and all of the associated messages. Then on the forum open a text box and paste the text.

The text box is important because it preserves formatting of diagnostic characters that SAS often provides AND then we can make corrections/suggestions by copying text, editing and pasting the modified text for you to use.

 

An example, different error but same cause: missing comma between select elements. Even with a different error we can tell where in code the issue is because we don't have to parse lots of stuff.  We can see it is likely around the "ABC:"

466  proc sql;
467     create table junk as
468     select sex
469     "ABC:"||put(weight,f5.1) as ref
              --
              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.

470     from sashelp.class
471     ;
472  quit;

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 596 views
  • 0 likes
  • 4 in conversation