BookmarkSubscribeRSS Feed
Wouter
Obsidian | Level 7
Hi,

I've created a (SAS) SQL query, but this generate a warning ("Function LEFT requires at most 1 argument(s). The extra one(s) will be ignored."). In Management Studio the query (this part) works great, but not in SAS. Can anyone see the problem?

The 'faulty' part:

WHEN LEFT(MAX(Addr.ZipCode),3) IN ('101', '102') OR MAX(Addr.ProvinceName) IN ('Berlin', 'Brandenburg') THEN 'E'
WHEN MAX(Addr.ProvinceName) IN ('Baden', 'Hamburg') THEN 'W' END AS RM_EW

Thanks for your answer!!

Message was edited by: Wouter Message was edited by: Wouter
7 REPLIES 7
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Was this test? Count your parenthesis characters in the expression below:

LEFT(MAX(Addr.ZipCode)),3)


Scott Barry
SBBWorks, Inc.
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Also, the SAS LEFT function is different than other programming language LEFT function behavior and specification. You will need to consider another approach such as using SUBSTR.

Scott Barry
SBBWorks, Inc.

SAS Language Reference: Dictionary - LEFT function:
http://support.sas.com/documentation/cdl/en/lrdict/62618/HTML/default/a000212224.htm
Wouter
Obsidian | Level 7
> Also, the SAS LEFT function is different than other
> programming language LEFT function behavior and
> specification. You will need to consider another
> approach such as using SUBSTR.
>
> Scott Barry
> SBBWorks, Inc.
>
> SAS Language Reference: Dictionary - LEFT function:
> http://support.sas.com/documentation/cdl/en/lrdict/626
> 18/HTML/default/a000212224.htm

But this is the LEFT function for DATA steps. I've wrote a SQL query (proc sql); the LEFT function should be the SQL 'version'?
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Who's SQL language should be your first question? Like the diagnostic states, only one argument is expected for the SAS LEFT function -- regardless of whether it is PROC SQL or DATA / PROC step invocation.

Scott Barry
SBBWorks, Inc.
Wouter
Obsidian | Level 7
> Who's SQL language should be your first question?
> Like the diagnostic states, only one argument is
> expected for the SAS LEFT function -- regardless of
> whether it is PROC SQL or DATA / PROC step
> invocation.
>
> Scott Barry
> SBBWorks, Inc.

Thank you for your answer. So if I understand correctly, SQL functions called within SAS SQL like "LEFT" can have another meaning/impact?
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Yes - It's somewhat (I'm stretching but it's beer:30 - sorry!) akin to the difference between "pot holder" and "roach clip" -- the first (that being LEFT) was already taken so they had to come up with another name -- the SAS function is SUBSTR.

Scott Barry
SBBWorks, Inc.
Wouter
Obsidian | Level 7
> Was this test? Count your parenthesis characters in
> the expression below:
>
> LEFT(MAX(Addr.ZipCode)),3)
>
>
> Scott Barry
> SBBWorks, Inc.

Hmmm... had tried some things with parenthesis, and forgot to delete one. But the warning didn't change after entering extra parenthesis. The correct version which created the warning was: LEFT(MAX(Addr.ZipCode),3) --> I've changed it now also in the 1st post. Thanks!

Message was edited by: Wouter Message was edited by: Wouter

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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