Show us the ENTIRE log for this PROC SQL (that's every single line in the log for this PROC SQL, that's every single character in the log for this PROC SQL, with nothing removed).
What is SUBSTRING()?
Did you mean SUBSTR()?
SUBSTR and SUBSTRING are equivalent:
Note: The SUBSTRING function is provided for compatibility with the ANSI SQL standard. You can also use the SAS function SUBSTR.
Perhaps in theory SAS supports SUBSTRING() as an alias for SUBSTR(), but in reality it does not.
68 69 %put &=sysvlong; SYSVLONG=9.04.01M7P080620 70 proc sql; 71 72 create table TEST as 73 select name,substr(name,1,5) as sub 74 from sashelp.class 75 ; NOTE: Table WORK.TEST created, with 19 rows and 2 columns. 76 create table TEST as 77 select name,substring(name,1,8) as sub _ __ 79 22 76 ERROR 79-322: Expecting a (. ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, -, /, <, <=, <>, =, >, >=, ?, AND, BETWEEN, CONTAINS, EQ, EQT, FROM, GE, GET, GT, GTT, IN, IS, LE, LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, ^, ^=, |, ||, ~, ~=. ERROR 76-322: Syntax error, statement will be ignored. 78 from sashelp.class 79 ; NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements. 80 quit; NOTE: The SAS System stopped processing this step because of errors. NOTE: PROCEDURE SQL used (Total process time): real time 0.00 seconds cpu time 0.00 seconds
The syntax of SUBSTRING is some perverse oververbose sql-eze instead of a simple function call.
proc sql;
create table TEST1 as
select name
, substring(name from 1 for 5) as sub1
, substr(name,1,5) as sub2
from sashelp.class
;
quit;
@Lakshmisukanya wrote:
The substr() function is used to extract a specific substring from a string. It takes in three parameters, the string to extract from, the starting position, and the length of the substring.
SHOW US THE LOG
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!
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.
Ready to level-up your skills? Choose your own adventure.