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 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 12171 views
  • 0 likes
  • 2 in conversation