<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic SAS SQL Length function in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-SQL-Length-function/m-p/747802#M19990</link>
    <description>&lt;P&gt;Hi there&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to perform the below SQL code in a proc sql in SAS&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SQL code:&lt;BR /&gt;select&lt;BR /&gt;reference&lt;BR /&gt;into&lt;BR /&gt;#Wi&lt;BR /&gt;from #all&lt;BR /&gt;where Reference in (select left(Reference ,len(Reference )-1)+ max(right(Reference ,1))&lt;BR /&gt;from stgw&lt;BR /&gt;group by left(Reference ,len(Reference )-1))&lt;BR /&gt;group by Reference , UCN1&lt;BR /&gt;order by ucn1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried:&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table Wi as&lt;/P&gt;&lt;P&gt;select&lt;BR /&gt;reference&lt;BR /&gt;from all&lt;BR /&gt;where Reference in (select left(Reference ,len(Reference )-1)+ max(right(Reference ,1))&lt;BR /&gt;from stgw&lt;BR /&gt;group by left(Reference ,substr(Reference, lenght(Reference)-1,0)))&lt;BR /&gt;group by Reference , UCN1&lt;BR /&gt;order by ucn1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error:&lt;/P&gt;&lt;P&gt;ERROR: Function LEN could not be located.&lt;BR /&gt;ERROR: Expression using subtraction (-) requires numeric types.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I perform the length function in SAS PROC SQL?&lt;/P&gt;</description>
    <pubDate>Mon, 14 Jun 2021 13:47:26 GMT</pubDate>
    <dc:creator>Citrine10</dc:creator>
    <dc:date>2021-06-14T13:47:26Z</dc:date>
    <item>
      <title>SAS SQL Length function</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-SQL-Length-function/m-p/747802#M19990</link>
      <description>&lt;P&gt;Hi there&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to perform the below SQL code in a proc sql in SAS&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SQL code:&lt;BR /&gt;select&lt;BR /&gt;reference&lt;BR /&gt;into&lt;BR /&gt;#Wi&lt;BR /&gt;from #all&lt;BR /&gt;where Reference in (select left(Reference ,len(Reference )-1)+ max(right(Reference ,1))&lt;BR /&gt;from stgw&lt;BR /&gt;group by left(Reference ,len(Reference )-1))&lt;BR /&gt;group by Reference , UCN1&lt;BR /&gt;order by ucn1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried:&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table Wi as&lt;/P&gt;&lt;P&gt;select&lt;BR /&gt;reference&lt;BR /&gt;from all&lt;BR /&gt;where Reference in (select left(Reference ,len(Reference )-1)+ max(right(Reference ,1))&lt;BR /&gt;from stgw&lt;BR /&gt;group by left(Reference ,substr(Reference, lenght(Reference)-1,0)))&lt;BR /&gt;group by Reference , UCN1&lt;BR /&gt;order by ucn1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error:&lt;/P&gt;&lt;P&gt;ERROR: Function LEN could not be located.&lt;BR /&gt;ERROR: Expression using subtraction (-) requires numeric types.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I perform the length function in SAS PROC SQL?&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jun 2021 13:47:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/SAS-SQL-Length-function/m-p/747802#M19990</guid>
      <dc:creator>Citrine10</dc:creator>
      <dc:date>2021-06-14T13:47:26Z</dc:date>
    </item>
    <item>
      <title>Re: SAS SQL Length function</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-SQL-Length-function/m-p/747810#M19991</link>
      <description>&lt;P&gt;Please explain what the original query is actually doing.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your syntax appears be mixing strings and numbers.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;left(Reference ,len(Reference )-1) + max(right(Reference ,1))&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The LEFT() function will move all of the leading spaces in a string to trailing spaces.&lt;/P&gt;
&lt;P&gt;The RIGHT() function will move all of the trailing spaces in a string to leading spaces.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Both only take one argument.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The MAX() SQL aggregate function will take the string that collates last for the group.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You then try to use addition with the resulting strings.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So what meaning does that strange code have in the original SQL dialect you were using?&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jun 2021 14:14:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/SAS-SQL-Length-function/m-p/747810#M19991</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-06-14T14:14:30Z</dc:date>
    </item>
    <item>
      <title>Re: SAS SQL Length function</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-SQL-Length-function/m-p/747818#M19992</link>
      <description>&lt;P&gt;It's called LEN&lt;EM&gt;GTH&lt;/EM&gt;() in SAS.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/n0f6jve4kdxnh1n1m7c82fhosgih.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/n0f6jve4kdxnh1n1m7c82fhosgih.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jun 2021 14:33:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/SAS-SQL-Length-function/m-p/747818#M19992</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2021-06-14T14:33:11Z</dc:date>
    </item>
  </channel>
</rss>

