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

Hi,

 

I am using SAS DI and trying to use Oracle CAST function to have integer result of division of one NUMBER attribute by 100.

 

Whatever I do, I get syntax error.

Tried:
(CAST ( {PERIOD_ID/100} AS INTEGER))

 

CAST(period_id/100 AS INTEGER)

 

etc ...

 

 

ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant,
a missing value, (, ), *, +, ',', -, ALL, BTRIM, CALCULATED, CASE, DISTINCT, EXISTS, INPUT, NOT, PUT, SUBSTRING,
TRANSLATE, UNIQUE, USER, ^, ~.

ERROR 200-322: The symbol is not recognized and will be ignored.

 

 

SAS code:
proc sql;
create table arpu01.WDPLPU as
select
PERIOD_ID,
LOAD_TYPE,
OWNER_CUSTOMER_KEY,
((CAST ( {PERIOD_ID/100} AS INTEGER))) as test1 length = 8
label = 'test1'
from &SYSLAST
;
quit;

 

The same goes for other options I tried.

I am doing something and I can't see it.


Any help is more than welcomed!

 

Thanks!

 

Best regards,

 

Mario.

--
Mario
1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

This is not the DI forum subgroup, and as such I do not use it.  However at a guess, I suspect your not actually connecting to an Oracle database, nor passing the SQL code through to one, correct?  If so then you cannot use Oracle functions in the SQL, only ANSI SQL statements are valid and Base SAS functions.  Therefore you would switch out cast() which is oracle only and use the SAS function int() (or round()):
((CAST ( {PERIOD_ID/100} AS INTEGER))) as test1 length = 8

 

To 

 

int(PERIOD_ID/100) as test1 length = 8

View solution in original post

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

This is not the DI forum subgroup, and as such I do not use it.  However at a guess, I suspect your not actually connecting to an Oracle database, nor passing the SQL code through to one, correct?  If so then you cannot use Oracle functions in the SQL, only ANSI SQL statements are valid and Base SAS functions.  Therefore you would switch out cast() which is oracle only and use the SAS function int() (or round()):
((CAST ( {PERIOD_ID/100} AS INTEGER))) as test1 length = 8

 

To 

 

int(PERIOD_ID/100) as test1 length = 8

strsljen
Obsidian | Level 7

Hi,

 

Thank you for the tip. That does the trick.

 

Best regards,

 

Mario.

--
Mario

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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
  • 2 replies
  • 2080 views
  • 0 likes
  • 2 in conversation