<?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: Using a Macro Variable inside a proc export in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-a-Macro-Variable-inside-a-proc-export/m-p/369270#M88145</link>
    <description>&lt;P&gt;Are you actually going to export the exact same data set to multiple files? Unless you change your Increment data set that will be the likely effect.&lt;/P&gt;</description>
    <pubDate>Wed, 21 Jun 2017 18:58:55 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2017-06-21T18:58:55Z</dc:date>
    <item>
      <title>Using a Macro Variable inside a proc export</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-Macro-Variable-inside-a-proc-export/m-p/369262#M88140</link>
      <description>&lt;P&gt;I am trying to create a sequence number to be placed at the end of a file name for a proc export.&lt;/P&gt;&lt;P&gt;Work.seq_nbr will contain the number I want to start with and then the datastep increment will increment that number by one and put a leading zero before it.&amp;nbsp; If the seq_nbr starts off at say 270 then I want 0271 to be &amp;amp;seq_nbr_pad in my proc export.&lt;/P&gt;&lt;P&gt;I just can't figure out how to make it a macro variable in my datastep or I need help in finding a way to do this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; increment(&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;keep&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=seq_nbr_pad);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;length&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; seq_nbr_txt $ &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;4&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt; seq_nbr_pad $ &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;4&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; work.seq_nbr;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#008000" face="Courier New" size="3"&gt;/* read charvar as number, then format with leading zeroes */&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#008000" face="Courier New" size="3"&gt;/* then put result into padded */&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;seq_nbr = seq_nbr+&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;seq_nbr_txt = put(seq_nbr,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;4.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;seq_nbr_pad = put(input(seq_nbr_txt,&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;best4.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;),&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;z4.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; seq_nbr=seq_nbr_pad;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;PROC&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;EXPORT&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;DATA&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=increment&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;OUTFILE&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"\\Home1\userid\GMF_&amp;amp;SEQ_NBR_PAD..csv"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;DBMS&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=CSV &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;REPLACE&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;RUN&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jun 2017 18:27:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-Macro-Variable-inside-a-proc-export/m-p/369262#M88140</guid>
      <dc:creator>sgtrun</dc:creator>
      <dc:date>2017-06-21T18:27:53Z</dc:date>
    </item>
    <item>
      <title>Re: Using a Macro Variable inside a proc export</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-Macro-Variable-inside-a-proc-export/m-p/369268#M88144</link>
      <description>&lt;P&gt;%LET can't be part of a DATA step.&amp;nbsp; Here's an alternative method to create your macro variable:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; _null_&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; work.seq_nbr (keep=seq_nbr);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;call symput('seq_nbr_pad', put(seq_nbr+1, z4.));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jun 2017 18:53:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-Macro-Variable-inside-a-proc-export/m-p/369268#M88144</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-06-21T18:53:51Z</dc:date>
    </item>
    <item>
      <title>Re: Using a Macro Variable inside a proc export</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-Macro-Variable-inside-a-proc-export/m-p/369270#M88145</link>
      <description>&lt;P&gt;Are you actually going to export the exact same data set to multiple files? Unless you change your Increment data set that will be the likely effect.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jun 2017 18:58:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-Macro-Variable-inside-a-proc-export/m-p/369270#M88145</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-06-21T18:58:55Z</dc:date>
    </item>
    <item>
      <title>Re: Using a Macro Variable inside a proc export</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-Macro-Variable-inside-a-proc-export/m-p/369272#M88146</link>
      <description>&lt;P&gt;Works perfectly.&amp;nbsp; Thank you so much.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jun 2017 18:59:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-Macro-Variable-inside-a-proc-export/m-p/369272#M88146</guid>
      <dc:creator>sgtrun</dc:creator>
      <dc:date>2017-06-21T18:59:09Z</dc:date>
    </item>
  </channel>
</rss>

