Hi all,
(I'm using DI Studio 4.901)
I'm trying to split a column of data i process with a file reader based on a delimiter into 2 new columns.
In EG this is easy to accomplish, but I cant seem to get this to convert over to my DIS transformation without an error.
my input column (web_atlas_ord_nbr) is a char20 with a pipe delimiter
my 2 new result columns are char20 as well.
my expression code is: SCAN(web_atlas_ord_nbr, 1) for new result column1 and SCAN(web_atlas_ord_nbr, -1) for new result column 2.
it passes the validate expression check, but when I run it... I get a syntax error:
500 (SCAN (web_atlas_ord_nbr, 1)) as web# length = 20
_
22
200
ERROR 22-322: Syntax error, expecting one of the following: a quoted string, ',', AS, FORMAT, FROM, INFORMAT, INTO, LABEL, LEN,
LENGTH, TRANSCODE.
ERROR 200-322: The symbol is not recognized and will be ignored.
I have attached some shots of the actual code and error.
Any help to understand what I'm doing worng would be greatly appreciated.
You need to post the SAS log records into a code block (use teh {i} icon on the editor tool bar) so we can see what character SAS is trying to underline that is causing the error.
To me it looks like you have a problem with the name of the target variable.
web#
is not a valid variable name.
You also can clean up the code for the SCAN function. You should tell it what your delimited is. Also if the source field only has one value in its list your second query will store capture it instead of generating blanks. Your probably want more like this:
scan(x,1,'|')
scan(x,2,'|')
You need to post the SAS log records into a code block (use teh {i} icon on the editor tool bar) so we can see what character SAS is trying to underline that is causing the error.
To me it looks like you have a problem with the name of the target variable.
web#
is not a valid variable name.
You also can clean up the code for the SCAN function. You should tell it what your delimited is. Also if the source field only has one value in its list your second query will store capture it instead of generating blanks. Your probably want more like this:
scan(x,1,'|')
scan(x,2,'|')
Don't put ANY expressions in a file reader, defer that to an extract node later in the job.
File Readers read, Table Loader load, neither should IMHO contain any "logic".
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!
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.