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

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.

 

 

 

 

 

 

 

- Chris N.
1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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,'|')

View solution in original post

3 REPLIES 3
Tom
Super User Tom
Super User

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,'|')
cnilsen
Quartz | Level 8
Tom,

as soon as I read your reply I realized the issue. I had this problem a while back when I tried to use the '#' as part of a column name. I changed it to _nbr for each new column and re-ran my code.. and it worked.
thanks for the help.. !
- Chris N.
AngusLooney
SAS Employee

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".

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to connect to databases in SAS Viya

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.

Discussion stats
  • 3 replies
  • 1297 views
  • 2 likes
  • 3 in conversation