<?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: concatenate variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/concatenate-variables/m-p/522910#M142018</link>
    <description>&lt;P&gt;wow, i would have never guessed that.&amp;nbsp; i guess quotes dont do in sas what they usually do.&amp;nbsp; usually it is a literal reference but...the quotes worked perfectly, thanks for your help everyone!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 20 Dec 2018 17:09:58 GMT</pubDate>
    <dc:creator>me55</dc:creator>
    <dc:date>2018-12-20T17:09:58Z</dc:date>
    <item>
      <title>concatenate variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/concatenate-variables/m-p/522904#M142013</link>
      <description>&lt;P&gt;okay, i am trying to build a table of differing date function results. the part i am having issues with is building a variable YYYY-xQ.&amp;nbsp; i need that value in QIDC and QIDP but the concatenating is not working and i do not understand why.&amp;nbsp; it is asking me for a mathematical operator in building a cat function.&amp;nbsp; i have used catx, catt, cats and || and it fails.&amp;nbsp; here is the code...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc sql;
create table DATES (
	TYPE char(10) format=$10. informat=$10.,
	DATE num format=MMDDYY8. informat=MMDDYY8.,
	CHAR char(10) format=$10. informat=$10.,
	NUM num format=6. informat=6.);
quit;

proc sql;
insert into DATES
	set TYPE='YTRDC'
	set TYPE='YTRDP'
	set TYPE='QTRC'
	set TYPE='QTRP'
	set TYPE='YRC'
	set TYPE='YRP'
	set TYPE='QIDC'
	set TYPE='QIDP'
	set TYPE='QIDX'
	set TYPE='QIDP';
quit;

proc sql;
update DATES
  set
	DATE=intnx('month',today(),-1)
	where TYPE='YTRDC';
quit;

proc sql;
update DATES
  set
	DATE=intnx('month',today(),-4)
	where TYPE='YTRDP';
quit;

proc sql;
update DATES
  set
	NUM=qtr(intnx('month',today(),-1))
	where TYPE='QTRC';
quit;

proc sql;
update DATES
  set
	NUM=qtr(intnx('month',today(),-4))
	where TYPE='QTRP';
quit;

proc sql;
select NUM
	into :var1
	from DATES
	where TYPE='QTRC';
quit;

proc sql;
select NUM
	into :var2
	from DATES
	where TYPE='QTRP';
quit;

proc sql;
update DATES
  set
	CHAR=cats('',&amp;amp;var1,'Q')
	where TYPE='QTRC';
quit;

proc sql;
update DATES
  set
	CHAR=cats('',&amp;amp;var2,'Q')
	where TYPE='QTRP';
quit;

proc sql;
update DATES
  set
	NUM=year(intnx('month',today(),-1))
	where TYPE='YRC';
quit;

proc sql;
update DATES
  set
	NUM=year(intnx('month',today(),-4))
	where TYPE='YRP';
quit;

proc sql;
update DATES
  set
	CHAR=put(year(intnx('month',today(),-1)),4.)
	where TYPE='YRC';
quit;

proc sql;
update DATES
  set
	CHAR=put(year(intnx('month',today(),-4)),4.)
	where TYPE='YRP';
quit;



proc sql;
select CHAR
	into :var3
	from DATES
	where TYPE='QTRC';
quit;

proc sql;
select CHAR
	into :var4
	from DATES
	where TYPE='YRC';
quit;

proc sql;
select CHAR
	into :var5
	from DATES
	where TYPE='QTRP';
quit;

proc sql;
select CHAR
	into :var6
	from DATES
	where TYPE='YRP';
quit;




proc sql;
update DATES
  set
	CHAR=&amp;amp;var3 || &amp;amp;var4
	where TYPE='QIDC';
quit;
	
proc sql;
update DATES
  set
	CHAR=cats('',&amp;amp;var5,'_',&amp;amp;var6)
	where TYPE='QIDP';
quit;&lt;/PRE&gt;&lt;P&gt;it is probably something simple but i dont get and the error is not helping...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;      GOPTIONS ACCESSIBLE;
24         proc sql;
25         update DATES
26           set
27         	CHAR=&amp;amp;var3 || &amp;amp;var4
NOTE: Line generated by the macro variable "VAR3".
27         4Q
            _
            22
ERROR 22-322: Syntax error, expecting one of the following: !!, *, **, +, -, /, WHERE, ||.  

28         	where TYPE='QIDC';
            _____
            22
            76
ERROR 22-322: Syntax error, expecting one of the following: ;, !, !!, &amp;amp;, *, **, +, -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;=, ?, AND, BETWEEN, 
              CONTAINS, EQ, EQT, GE, GET, GT, GTT, IN, IS, LE, LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, ^, ^=, |, ||, ~, ~=.  

ERROR 76-322: Syntax error, statement will be ignored.

NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
29         quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.00 seconds
      user cpu time       0.00 seconds
      system cpu time     0.00 seconds
      memory              40.59k
      OS Memory           19872.00k
      Timestamp           12/20/2018 10:56:26 AM
      Step Count                        153  Switch Count  68
      Page Faults                       7
      Page Reclaims                     21
      Page Swaps                        0
      Voluntary Context Switches        217
2                                                          The SAS System                          08:12 Thursday, December 20, 2018

      Involuntary Context Switches      0
      Block Input Operations            64
      Block Output Operations           8
      
30         	


31         proc sql;
32         update DATES
33           set
34         	CHAR=cats('',&amp;amp;var5,'_',&amp;amp;var6)
NOTE: Line generated by the macro variable "VAR5".
34         3Q
            _
            22
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, *, **, +, ',', -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;=, ?, AND, CONTAINS, 
              EQ, EQT, GE, GET, GT, GTT, LE, LET, LIKE, LT, LTT, NE, NET, OR, ^=, |, ||, ~=.  

35         	where TYPE='QIDP';
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
36         quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Dec 2018 16:56:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/concatenate-variables/m-p/522904#M142013</guid>
      <dc:creator>me55</dc:creator>
      <dc:date>2018-12-20T16:56:47Z</dc:date>
    </item>
    <item>
      <title>Re: concatenate variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/concatenate-variables/m-p/522905#M142014</link>
      <description>&lt;P&gt;Difficult to look through all your code but a quick spot on the error log tells me&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;   	CHAR=&amp;amp;var3 || &amp;amp;var4&lt;/PRE&gt;
&lt;P&gt;should be&lt;/P&gt;
&lt;PRE&gt;   	CHAR="&amp;amp;var3"||"&amp;amp;var4"&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Dec 2018 16:59:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/concatenate-variables/m-p/522905#M142014</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-12-20T16:59:51Z</dc:date>
    </item>
    <item>
      <title>Re: concatenate variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/concatenate-variables/m-p/522906#M142015</link>
      <description>&lt;P&gt;Macro variables that are text can be either variable names or text values. If there are no quotes it's interpreted as a variable, if it's in quotes, it's text.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Put &amp;amp;var3, &amp;amp;var4 ... etc in quotes and it works fine.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
update DATES
  set
	CHAR=catt("&amp;amp;var3",  "&amp;amp;var4")
	where TYPE='QIDC';
quit;
	
proc sql;
update DATES
  set
	CHAR=cats('',"&amp;amp;var5",'_',"&amp;amp;var6")
	where TYPE='QIDP';
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/113010"&gt;@me55&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;okay, i am trying to build a table of differing date function results. the part i am having issues with is building a variable YYYY-xQ.&amp;nbsp; i need that value in QIDC and QIDP but the concatenating is not working and i do not understand why.&amp;nbsp; it is asking me for a mathematical operator in building a cat function.&amp;nbsp; i have used catx, catt, cats and || and it fails.&amp;nbsp; here is the code...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql;
create table DATES (
	TYPE char(10) format=$10. informat=$10.,
	DATE num format=MMDDYY8. informat=MMDDYY8.,
	CHAR char(10) format=$10. informat=$10.,
	NUM num format=6. informat=6.);
quit;

proc sql;
insert into DATES
	set TYPE='YTRDC'
	set TYPE='YTRDP'
	set TYPE='QTRC'
	set TYPE='QTRP'
	set TYPE='YRC'
	set TYPE='YRP'
	set TYPE='QIDC'
	set TYPE='QIDP'
	set TYPE='QIDX'
	set TYPE='QIDP';
quit;

proc sql;
update DATES
  set
	DATE=intnx('month',today(),-1)
	where TYPE='YTRDC';
quit;

proc sql;
update DATES
  set
	DATE=intnx('month',today(),-4)
	where TYPE='YTRDP';
quit;

proc sql;
update DATES
  set
	NUM=qtr(intnx('month',today(),-1))
	where TYPE='QTRC';
quit;

proc sql;
update DATES
  set
	NUM=qtr(intnx('month',today(),-4))
	where TYPE='QTRP';
quit;

proc sql;
select NUM
	into :var1
	from DATES
	where TYPE='QTRC';
quit;

proc sql;
select NUM
	into :var2
	from DATES
	where TYPE='QTRP';
quit;

proc sql;
update DATES
  set
	CHAR=cats('',&amp;amp;var1,'Q')
	where TYPE='QTRC';
quit;

proc sql;
update DATES
  set
	CHAR=cats('',&amp;amp;var2,'Q')
	where TYPE='QTRP';
quit;

proc sql;
update DATES
  set
	NUM=year(intnx('month',today(),-1))
	where TYPE='YRC';
quit;

proc sql;
update DATES
  set
	NUM=year(intnx('month',today(),-4))
	where TYPE='YRP';
quit;

proc sql;
update DATES
  set
	CHAR=put(year(intnx('month',today(),-1)),4.)
	where TYPE='YRC';
quit;

proc sql;
update DATES
  set
	CHAR=put(year(intnx('month',today(),-4)),4.)
	where TYPE='YRP';
quit;



proc sql;
select CHAR
	into :var3
	from DATES
	where TYPE='QTRC';
quit;

proc sql;
select CHAR
	into :var4
	from DATES
	where TYPE='YRC';
quit;

proc sql;
select CHAR
	into :var5
	from DATES
	where TYPE='QTRP';
quit;

proc sql;
select CHAR
	into :var6
	from DATES
	where TYPE='YRP';
quit;




proc sql;
update DATES
  set
	CHAR=&amp;amp;var3 || &amp;amp;var4
	where TYPE='QIDC';
quit;
	
proc sql;
update DATES
  set
	CHAR=cats('',&amp;amp;var5,'_',&amp;amp;var6)
	where TYPE='QIDP';
quit;&lt;/PRE&gt;
&lt;P&gt;it is probably something simple but i dont get and the error is not helping...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;      GOPTIONS ACCESSIBLE;
24         proc sql;
25         update DATES
26           set
27         	CHAR=&amp;amp;var3 || &amp;amp;var4
NOTE: Line generated by the macro variable "VAR3".
27         4Q
            _
            22
ERROR 22-322: Syntax error, expecting one of the following: !!, *, **, +, -, /, WHERE, ||.  

28         	where TYPE='QIDC';
            _____
            22
            76
ERROR 22-322: Syntax error, expecting one of the following: ;, !, !!, &amp;amp;, *, **, +, -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;=, ?, AND, BETWEEN, 
              CONTAINS, EQ, EQT, GE, GET, GT, GTT, IN, IS, LE, LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, ^, ^=, |, ||, ~, ~=.  

ERROR 76-322: Syntax error, statement will be ignored.

NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
29         quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.00 seconds
      user cpu time       0.00 seconds
      system cpu time     0.00 seconds
      memory              40.59k
      OS Memory           19872.00k
      Timestamp           12/20/2018 10:56:26 AM
      Step Count                        153  Switch Count  68
      Page Faults                       7
      Page Reclaims                     21
      Page Swaps                        0
      Voluntary Context Switches        217
2                                                          The SAS System                          08:12 Thursday, December 20, 2018

      Involuntary Context Switches      0
      Block Input Operations            64
      Block Output Operations           8
      
30         	


31         proc sql;
32         update DATES
33           set
34         	CHAR=cats('',&amp;amp;var5,'_',&amp;amp;var6)
NOTE: Line generated by the macro variable "VAR5".
34         3Q
            _
            22
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, *, **, +, ',', -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;=, ?, AND, CONTAINS, 
              EQ, EQT, GE, GET, GT, GTT, LE, LET, LIKE, LT, LTT, NE, NET, OR, ^=, |, ||, ~=.  

35         	where TYPE='QIDP';
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
36         quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Dec 2018 17:02:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/concatenate-variables/m-p/522906#M142015</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-12-20T17:02:03Z</dc:date>
    </item>
    <item>
      <title>Re: concatenate variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/concatenate-variables/m-p/522907#M142016</link>
      <description>&lt;P&gt;And for concatenation,instead of the || operator in your&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;CHAR=&amp;amp;var3 || &amp;amp;var4&lt;/PRE&gt;
&lt;P&gt;I would rather resolve without the concat || operator like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;CHAR="&amp;amp;var3&amp;amp;var4"&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Dec 2018 17:03:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/concatenate-variables/m-p/522907#M142016</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-12-20T17:03:35Z</dc:date>
    </item>
    <item>
      <title>Re: concatenate variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/concatenate-variables/m-p/522910#M142018</link>
      <description>&lt;P&gt;wow, i would have never guessed that.&amp;nbsp; i guess quotes dont do in sas what they usually do.&amp;nbsp; usually it is a literal reference but...the quotes worked perfectly, thanks for your help everyone!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Dec 2018 17:09:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/concatenate-variables/m-p/522910#M142018</guid>
      <dc:creator>me55</dc:creator>
      <dc:date>2018-12-20T17:09:58Z</dc:date>
    </item>
  </channel>
</rss>

