<?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: Append a string to a macro variable for name  of output data set. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Append-a-string-to-a-macro-variable-for-name-of-output-data-set/m-p/599207#M172946</link>
    <description>&lt;P&gt;You may also need the double dots on this line&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: #333333; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 150%; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt; SET &amp;amp;&amp;amp;TBL..&amp;amp;i ;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 25 Oct 2019 01:07:29 GMT</pubDate>
    <dc:creator>VDD</dc:creator>
    <dc:date>2019-10-25T01:07:29Z</dc:date>
    <item>
      <title>Append a string to a macro variable for name  of output data set.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Append-a-string-to-a-macro-variable-for-name-of-output-data-set/m-p/599169#M172941</link>
      <description>&lt;P&gt;The code below&amp;nbsp; works fine.&amp;nbsp; The output file is the same as the input with 'TBL_' added as a name prefix.&amp;nbsp; However, when I try to append&amp;nbsp; '_TBL' as a suffix,&amp;nbsp; rather than prefix, the step fails thinking that the '_TBL' is part of the macro variable name.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%MACRO PREP_TBL;&lt;BR /&gt;&lt;BR /&gt;%DO I = 1 %TO 3 ;&lt;BR /&gt;DATA TBL_&amp;amp;&amp;amp;TBL&amp;amp;i|' ;&lt;BR /&gt;SET &amp;amp;&amp;amp;TBL&amp;amp;i ;&lt;BR /&gt;WHERE DATE_ID GE 20160701 AND DATE_ID LE 20180630 ;&lt;BR /&gt;RUN;&lt;BR /&gt;%END ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%PREP_TBL ;&lt;BR /&gt;&lt;BR /&gt;%MEND;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Oct 2019 21:11:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Append-a-string-to-a-macro-variable-for-name-of-output-data-set/m-p/599169#M172941</guid>
      <dc:creator>ncvol82</dc:creator>
      <dc:date>2019-10-24T21:11:02Z</dc:date>
    </item>
    <item>
      <title>Re: Append a string to a macro variable for name  of output data set.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Append-a-string-to-a-macro-variable-for-name-of-output-data-set/m-p/599174#M172942</link>
      <description>&lt;P&gt;Show us the code that doesn't work.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Oct 2019 21:27:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Append-a-string-to-a-macro-variable-for-name-of-output-data-set/m-p/599174#M172942</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-10-24T21:27:48Z</dc:date>
    </item>
    <item>
      <title>Re: Append a string to a macro variable for name  of output data set.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Append-a-string-to-a-macro-variable-for-name-of-output-data-set/m-p/599177#M172943</link>
      <description>&lt;P&gt;%MACRO PREP_TBL;&lt;BR /&gt;34&lt;BR /&gt;35 %DO I = 1 %TO 1 ;&lt;BR /&gt;36 DATA &amp;amp;&amp;amp;TBL&amp;amp;i._TBL ;&lt;BR /&gt;37 SET &amp;amp;&amp;amp;TBL&amp;amp;i ;&lt;BR /&gt;38 WHERE DATE_ID GE 20160701 AND DATE_ID LE 20180630 ;&lt;BR /&gt;39 TRAN_DT = INPUT(PUT(DATE_ID,Z8.),YYMMDD8.) ;&lt;BR /&gt;40 TRAN_DYOFWK = WEEKDAY(TRAN_DT) ;&lt;BR /&gt;41 TRAN_REMDAYS = 7 - TRAN_DYOFWK ;&lt;BR /&gt;42 TRAN_WKEND = TRAN_DT + (TRAN_REMDAYS) ;&lt;BR /&gt;43 FORMAT TRAN_DT TRAN_WKEND MMDDYY10. ;&lt;BR /&gt;44 DROP TRAN_REMDAYS TRAN_DYOFWK ;&lt;BR /&gt;45 RUN;&lt;BR /&gt;46 %END ;&lt;BR /&gt;47&lt;BR /&gt;48 proc sort ;&lt;BR /&gt;49 by LOAN_ID TRAN_WKEND TRAN_DT ;&lt;BR /&gt;50 run;&lt;BR /&gt;51&lt;BR /&gt;52 %MEND;&lt;BR /&gt;53&lt;BR /&gt;54 %PREP_TBL;&lt;BR /&gt;MLOGIC(PREP_TBL): Beginning execution.&lt;BR /&gt;MLOGIC(PREP_TBL): %DO loop beginning; index variable I; start value is 1; stop value is 1; by value is 1.&lt;BR /&gt;SYMBOLGEN: &amp;amp;&amp;amp; resolves to &amp;amp;.&lt;BR /&gt;SYMBOLGEN: Macro variable I resolves to 1&lt;BR /&gt;WARNING: Apparent symbolic reference TBL1_TBL not resolved.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Oct 2019 21:39:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Append-a-string-to-a-macro-variable-for-name-of-output-data-set/m-p/599177#M172943</guid>
      <dc:creator>ncvol82</dc:creator>
      <dc:date>2019-10-24T21:39:10Z</dc:date>
    </item>
    <item>
      <title>Re: Append a string to a macro variable for name  of output data set.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Append-a-string-to-a-macro-variable-for-name-of-output-data-set/m-p/599180#M172945</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA &amp;amp;&amp;amp;TBL&amp;amp;i.._TBL ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Use two dots to end a macro variable reference that begins with &lt;FONT face="courier new,courier"&gt;&amp;amp;&amp;amp;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Oct 2019 21:43:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Append-a-string-to-a-macro-variable-for-name-of-output-data-set/m-p/599180#M172945</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-10-24T21:43:34Z</dc:date>
    </item>
    <item>
      <title>Re: Append a string to a macro variable for name  of output data set.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Append-a-string-to-a-macro-variable-for-name-of-output-data-set/m-p/599207#M172946</link>
      <description>&lt;P&gt;You may also need the double dots on this line&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: #333333; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 150%; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt; SET &amp;amp;&amp;amp;TBL..&amp;amp;i ;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Oct 2019 01:07:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Append-a-string-to-a-macro-variable-for-name-of-output-data-set/m-p/599207#M172946</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2019-10-25T01:07:29Z</dc:date>
    </item>
    <item>
      <title>Re: Append a string to a macro variable for name  of output data set.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Append-a-string-to-a-macro-variable-for-name-of-output-data-set/m-p/599253#M172947</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/296732"&gt;@ncvol82&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;The code below&amp;nbsp; works fine.&amp;nbsp; The output file is the same as the input with 'TBL_' added as a name prefix.&amp;nbsp; However, when I try to append&amp;nbsp; '_TBL' as a suffix,&amp;nbsp; rather than prefix, the step fails thinking that the '_TBL' is part of the macro variable name.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%MACRO PREP_TBL;&lt;BR /&gt;&lt;BR /&gt;%DO I = 1 %TO 3 ;&lt;BR /&gt;DATA TBL_&amp;amp;&amp;amp;TBL&amp;amp;i|' ;&lt;BR /&gt;SET &amp;amp;&amp;amp;TBL&amp;amp;i ;&lt;BR /&gt;WHERE DATE_ID GE 20160701 AND DATE_ID LE 20180630 ;&lt;BR /&gt;RUN;&lt;BR /&gt;%END ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%PREP_TBL ;&lt;BR /&gt;&lt;BR /&gt;%MEND;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This code cannot work, as the pipe character and a single quote are not allowed in SAS names.&lt;/P&gt;
&lt;P&gt;You also have a data design problem, as you seem to store dates as funny numbers and not as SAS date values.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Oct 2019 07:37:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Append-a-string-to-a-macro-variable-for-name-of-output-data-set/m-p/599253#M172947</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-10-25T07:37:49Z</dc:date>
    </item>
    <item>
      <title>Re: Append a string to a macro variable for name  of output data set.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Append-a-string-to-a-macro-variable-for-name-of-output-data-set/m-p/599320#M172988</link>
      <description>&lt;P&gt;You can fix it with making sure you tell SAS where your macro variable reference ends.&lt;/P&gt;
&lt;P&gt;But why bother.&amp;nbsp; Just take the time to write out the steps and neither SAS nor you will get confused about what you are trying to do.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro prep_tbl;
%local i in out;
%do i = 1 %to 1 ;
  %let in=&amp;amp;&amp;amp;tbl&amp;amp;i;
  %let out=&amp;amp;in._tbl;

data &amp;amp;out;
  set &amp;amp;in;
  where date_id ge 20160701 and date_id le 20180630 ;
  tran_dt = input(put(date_id,z8.),yymmdd8.) ;
  tran_dyofwk = weekday(tran_dt) ;
  tran_remdays = 7 - tran_dyofwk ;
  tran_wkend = tran_dt + (tran_remdays) ;
  format tran_dt tran_wkend mmddyy10. ;
  drop tran_remdays tran_dyofwk ;
run;

%end ;

%mend prep_tbl;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 25 Oct 2019 13:35:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Append-a-string-to-a-macro-variable-for-name-of-output-data-set/m-p/599320#M172988</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-10-25T13:35:21Z</dc:date>
    </item>
    <item>
      <title>Re: Append a string to a macro variable for name  of output data set.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Append-a-string-to-a-macro-variable-for-name-of-output-data-set/m-p/599326#M172992</link>
      <description>&lt;P&gt;The two dots worked.&amp;nbsp; Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Oct 2019 13:48:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Append-a-string-to-a-macro-variable-for-name-of-output-data-set/m-p/599326#M172992</guid>
      <dc:creator>ncvol82</dc:creator>
      <dc:date>2019-10-25T13:48:37Z</dc:date>
    </item>
  </channel>
</rss>

