<?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: concatenating the substring of a global variable in proc sql in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/concatenating-the-substring-of-a-global-variable-in-proc-sql/m-p/420149#M67862</link>
    <description>&lt;P&gt;quick correction&amp;nbsp; it should be&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;CATX(' ',SUBSTR("&amp;amp;CY.",3,4),"&amp;amp;PERIOD.") AS PERIOD,&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 11 Dec 2017 15:27:22 GMT</pubDate>
    <dc:creator>joseatmc1</dc:creator>
    <dc:date>2017-12-11T15:27:22Z</dc:date>
    <item>
      <title>concatenating the substring of a global variable in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/concatenating-the-substring-of-a-global-variable-in-proc-sql/m-p/420130#M67859</link>
      <description>&lt;P&gt;I have what I thought was a simple thing to do ,but ended up being more difficult.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a global variable called &amp;amp;CY.&amp;nbsp; that is = to "FY2017" and another &amp;amp;PERIOD. that is equal "11" (BOTH ARE CHARACTER VALUES).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in&amp;nbsp; a proc sql statement I'm trying to create a column called Period that concatenates the year part of FY2017 to the Period.&lt;/P&gt;&lt;P&gt;&amp;nbsp;below is the&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;PRE&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
CREATE TABLE SAS_DATA.CUST_PVM_PTD_&amp;amp;PERIOD.&amp;amp;FY. AS
SELECT "CUSTPVM" AS DATA_SOURCE,"COMPONENTS" AS PRICING_TYPE,"COMPONENTS" AS PRICING_TYPE_LESS_RECON,
CATX(' ',SUBSTR(&amp;amp;CY.,2,4),&amp;amp;PERIOD.) AS PERIOD, &lt;/CODE&gt;&lt;/FONT&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;I'm getting the following errors &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;ERROR: The following columns were not found in the contributing tables: FY2017.&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;This isn't working&amp;nbsp; I'm not trying to concatenate and entire column, just want each row to say "201711"&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Dec 2017 14:59:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/concatenating-the-substring-of-a-global-variable-in-proc-sql/m-p/420130#M67859</guid>
      <dc:creator>joseatmc1</dc:creator>
      <dc:date>2017-12-11T14:59:14Z</dc:date>
    </item>
    <item>
      <title>Re: concatenating the substring of a global variable in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/concatenating-the-substring-of-a-global-variable-in-proc-sql/m-p/420146#M67860</link>
      <description>&lt;P&gt;Please format code so that it is readable - i.e. not all uppercase, indented, new row for each line etc.&amp;nbsp; Trying to debug a solid line of shouting is not fun.&amp;nbsp; Anyways, you are resolving your macro to this:&lt;/P&gt;
&lt;PRE&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token function"&gt;CATX&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;' '&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;SUBSTR&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;FY2017&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;2&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;4&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;11&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;As you can see, once resolution has happened, it now looks like you want to substr a variable called fy2017, and concat a variable 11 - which is invalid.&amp;nbsp; What you want is:&lt;/P&gt;
&lt;PRE&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token function"&gt;CATX&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;' '&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;SUBSTR&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;("&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;CY&lt;SPAN class="token punctuation"&gt;."&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;2&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;4&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,"&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;PERIOD&lt;SPAN class="token punctuation"&gt;."&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;Note the double quotes around them.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Dec 2017 15:16:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/concatenating-the-substring-of-a-global-variable-in-proc-sql/m-p/420146#M67860</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-12-11T15:16:37Z</dc:date>
    </item>
    <item>
      <title>Re: concatenating the substring of a global variable in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/concatenating-the-substring-of-a-global-variable-in-proc-sql/m-p/420148#M67861</link>
      <description>&lt;P&gt;sorry RW9 . I'm new to all these boards I apologize for shouting. I had tried quotes before but I was using single quotes, because I thought single quotes allowed for the global variables/formulas. but I guess it's the double quotes that do that. right?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think that is working correctly now.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you so much!&lt;/P&gt;</description>
      <pubDate>Mon, 11 Dec 2017 15:24:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/concatenating-the-substring-of-a-global-variable-in-proc-sql/m-p/420148#M67861</guid>
      <dc:creator>joseatmc1</dc:creator>
      <dc:date>2017-12-11T15:24:39Z</dc:date>
    </item>
    <item>
      <title>Re: concatenating the substring of a global variable in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/concatenating-the-substring-of-a-global-variable-in-proc-sql/m-p/420149#M67862</link>
      <description>&lt;P&gt;quick correction&amp;nbsp; it should be&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;CATX(' ',SUBSTR("&amp;amp;CY.",3,4),"&amp;amp;PERIOD.") AS PERIOD,&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Dec 2017 15:27:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/concatenating-the-substring-of-a-global-variable-in-proc-sql/m-p/420149#M67862</guid>
      <dc:creator>joseatmc1</dc:creator>
      <dc:date>2017-12-11T15:27:22Z</dc:date>
    </item>
    <item>
      <title>Re: concatenating the substring of a global variable in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/concatenating-the-substring-of-a-global-variable-in-proc-sql/m-p/420155#M67863</link>
      <description>&lt;P&gt;Yes, only double quote marks will allow macro information within a string to be resolved, singles quotes will just treat the whole bit as plain text.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Dec 2017 15:37:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/concatenating-the-substring-of-a-global-variable-in-proc-sql/m-p/420155#M67863</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-12-11T15:37:25Z</dc:date>
    </item>
  </channel>
</rss>

