<?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 Re: SUBSTR field and JOIN in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SUBSTR-field-and-JOIN/m-p/921390#M44518</link>
    <description>&lt;P&gt;&lt;SPAN&gt;From now on, when you have an error in a PROC, show us the log for that PROC. We need to see the code as it appears in the log, and any messages such as errors, warnings and noes. DO NOT show us just the error messages in the log, detached from the code in the log.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;substr('c_key',1,5) AS a.cid&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;a.cid is not a valid variable name in SAS. You can only use letters, numbers and underscores in variable names. You cannot use a dot in variable names.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Although that code seems suspicious to me because substr('c_key',1,5) is a constant with value 'c_key', why would you do that?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 21 Mar 2024 19:59:34 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2024-03-21T19:59:34Z</dc:date>
    <item>
      <title>SUBSTR field and JOIN</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SUBSTR-field-and-JOIN/m-p/921385#M44517</link>
      <description>&lt;P&gt;Need help with the following:&lt;/P&gt;
&lt;P&gt;tableA has c_key that looks like hhh-123456789 where tableB has cid like 123456789. I need to remove the first four (hhh-) from the c_key in tableA so that I can join on cid in tableB. I did a substr but I am getting the following error:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
     create tableC
        select a.*,
               b.pl_svc as svc,
               b.grp_cd as grp,
	       substr('c_key',1,5) AS a.cid
                                       -
                                       22
                                       76
ERROR 22-322: Syntax error, expecting one of the following: a quoted string, ',', AS, FORMAT, FROM, INFORMAT, INTO, LABEL, LEN, 
              LENGTH, TRANSCODE.  
ERROR 76-322: Syntax error, statement will be ignored.&lt;BR /&gt;
           from tableA a
              LEFT JOIN tableB as b
                 on a.cid = b.cid

    
quit;


&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Mar 2024 19:46:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SUBSTR-field-and-JOIN/m-p/921385#M44517</guid>
      <dc:creator>bhca60</dc:creator>
      <dc:date>2024-03-21T19:46:44Z</dc:date>
    </item>
    <item>
      <title>Re: SUBSTR field and JOIN</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SUBSTR-field-and-JOIN/m-p/921390#M44518</link>
      <description>&lt;P&gt;&lt;SPAN&gt;From now on, when you have an error in a PROC, show us the log for that PROC. We need to see the code as it appears in the log, and any messages such as errors, warnings and noes. DO NOT show us just the error messages in the log, detached from the code in the log.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;substr('c_key',1,5) AS a.cid&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;a.cid is not a valid variable name in SAS. You can only use letters, numbers and underscores in variable names. You cannot use a dot in variable names.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Although that code seems suspicious to me because substr('c_key',1,5) is a constant with value 'c_key', why would you do that?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2024 19:59:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SUBSTR-field-and-JOIN/m-p/921390#M44518</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-03-21T19:59:34Z</dc:date>
    </item>
    <item>
      <title>Re: SUBSTR field and JOIN</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SUBSTR-field-and-JOIN/m-p/921391#M44519</link>
      <description>&lt;P&gt;Actually has nothing to do with the Join, Substr but the name of the variable. When you say A.CID you should be addressing a variable CID that exists in the data set with the alias name of A. You are selecting into a new table so you don't use the alias as the result, barring other syntax issues, will be the name of the variable in the newly created data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example of wrong and right:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;689  proc sql;
690     create table junk as
691     select substr(a.name,1,2) as a.name
                                      -
                                      22
                                      76
ERROR 22-322: Syntax error, expecting one of the following: a quoted string, ',', AS, FORMAT,
              FROM, INFORMAT, INTO, LABEL, LEN, LENGTH, TRANSCODE.

ERROR 76-322: Syntax error, statement will be ignored.

692     from sashelp.class as a
693     ;
694  quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds



695  proc sql;
696     create table junk as
697     select substr(a.name,1,2) as name
698     from sashelp.class as a
699     ;
NOTE: Table USER.JUNK created, with 19 rows and 1 columns.

700  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds


&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/290946"&gt;@bhca60&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Need help with the following:&lt;/P&gt;
&lt;P&gt;tableA has c_key that looks like hhh-123456789 where tableB has cid like 123456789. I need to remove the first four (hhh-) from the c_key in tableA so that I can join on cid in tableB. I did a substr but I am getting the following error:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
     create tableC
        select a.*,
               b.pl_svc as svc,
               b.grp_cd as grp,
	       substr('c_key',1,5) AS a.cid
                                       -
                                       22
                                       76
ERROR 22-322: Syntax error, expecting one of the following: a quoted string, ',', AS, FORMAT, FROM, INFORMAT, INTO, LABEL, LEN, 
              LENGTH, TRANSCODE.  
ERROR 76-322: Syntax error, statement will be ignored.&lt;BR /&gt;
           from tableA a
              LEFT JOIN tableB as b
                 on a.cid = b.cid

    
quit;


&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2024 20:03:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SUBSTR-field-and-JOIN/m-p/921391#M44519</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-03-21T20:03:53Z</dc:date>
    </item>
    <item>
      <title>Re: SUBSTR field and JOIN</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SUBSTR-field-and-JOIN/m-p/921403#M44521</link>
      <description>&lt;P&gt;Hmm it's still showing as hhh-123456789; is the string correct for when you want to remove the first 4 from a character?&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2024 20:43:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SUBSTR-field-and-JOIN/m-p/921403#M44521</guid>
      <dc:creator>bhca60</dc:creator>
      <dc:date>2024-03-21T20:43:49Z</dc:date>
    </item>
    <item>
      <title>Re: SUBSTR field and JOIN</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SUBSTR-field-and-JOIN/m-p/921404#M44522</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/290946"&gt;@bhca60&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hmm it's still showing as hhh-123456789; is the string correct for when you want to remove the first 4 from a character?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You use the pronoun "it" and I find this to be completely unclear. What is "it" referring to?&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2024 20:47:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SUBSTR-field-and-JOIN/m-p/921404#M44522</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-03-21T20:47:17Z</dc:date>
    </item>
    <item>
      <title>Re: SUBSTR field and JOIN</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SUBSTR-field-and-JOIN/m-p/921413#M44523</link>
      <description>Need to change hhh-123456789 to 123456789; need to remove hhh-</description>
      <pubDate>Thu, 21 Mar 2024 21:12:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SUBSTR-field-and-JOIN/m-p/921413#M44523</guid>
      <dc:creator>bhca60</dc:creator>
      <dc:date>2024-03-21T21:12:45Z</dc:date>
    </item>
    <item>
      <title>Re: SUBSTR field and JOIN</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SUBSTR-field-and-JOIN/m-p/921416#M44524</link>
      <description>&lt;P&gt;To remove the first 4 characters, the syntax for SUBSTR would look like SUBSTR(c_key,5). The 2nd argument determines what position you want to start reading the value, and if there is no 3rd argument, it will read the rest of the value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;17 data a;&lt;BR /&gt;18 c_key='hhh-123456789';&lt;BR /&gt;19 run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NOTE: The data set WORK.A has 1 observations and 1 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.01 seconds&lt;BR /&gt;cpu time 0.00 seconds&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;20&lt;BR /&gt;21 data b;&lt;BR /&gt;22 set a;&lt;BR /&gt;23 new=substr(c_key,5);&lt;BR /&gt;24 put c_key= new=;&lt;BR /&gt;25 run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;c_key=hhh-123456789 new=123456789&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;NOTE: There were 1 observations read from the data set WORK.A.&lt;BR /&gt;NOTE: The data set WORK.B has 1 observations and 2 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.01 seconds&lt;BR /&gt;cpu time 0.00 seconds&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2024 21:43:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SUBSTR-field-and-JOIN/m-p/921416#M44524</guid>
      <dc:creator>jebjur</dc:creator>
      <dc:date>2024-03-21T21:43:48Z</dc:date>
    </item>
    <item>
      <title>Re: SUBSTR field and JOIN</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SUBSTR-field-and-JOIN/m-p/921445#M44525</link>
      <description>Thank you; how can I do this in proc sql step ? Because I want to include it in a proc sql table I need to run without creating a separate data set.&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;&lt;BR /&gt;substr(a.c_key,5) as cid&lt;BR /&gt;&lt;BR /&gt;from tableA a&lt;BR /&gt;left join tableB b&lt;BR /&gt;on a.cid=b.cid;&lt;BR /&gt;quit;</description>
      <pubDate>Fri, 22 Mar 2024 04:16:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SUBSTR-field-and-JOIN/m-p/921445#M44525</guid>
      <dc:creator>bhca60</dc:creator>
      <dc:date>2024-03-22T04:16:12Z</dc:date>
    </item>
  </channel>
</rss>

