<?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: Variable in PROC EXPORT outfile in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Variable-in-PROC-EXPORT-outfile/m-p/179219#M45757</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are using the macro statement %let erroneously in the data step. Macro directives (%... statements and &amp;amp;.... variables) are executed by the macro processor BEFORE the data step is compiled and executed.&lt;/P&gt;&lt;P&gt;So you get a macro variable mmyyyy with the value &lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;cat(-,Premonat,Jahr)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;Use call symput instead to export values from a data step into a macro variable.&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 20 Nov 2014 12:19:01 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2014-11-20T12:19:01Z</dc:date>
    <item>
      <title>Variable in PROC EXPORT outfile</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Variable-in-PROC-EXPORT-outfile/m-p/179218#M45756</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am pretty new to sas programming and I am kind of stuck trying to move two variables as outfile-directory.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I'm trying to do is filling up the filename of my exported text file with the last month and the current year.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So if someone runs the sas programme today the filename would be "filename-10-2014.txt"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I already have a code snippet which does work. But what it does, is inserting the whole current date into the filename:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let Datum = &amp;amp;SYSDATE9;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="; color: #000080; font-size: 12pt; font-family: Courier New;"&gt;&lt;STRONG&gt;export&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;data&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;=SASUSER.GEBDATUM&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;outfile&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;= &lt;/SPAN&gt;&lt;SPAN style="color: #800080; font-size: 12pt; font-family: Courier New;"&gt;"X:\filename-&amp;amp;Datum..txt"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;dbms&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;=tab&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;replace&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;Delimiter&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #800080; font-size: 12pt; font-family: Courier New;"&gt;';'&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;putnames&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;=no;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;Now I am trying to format the Date by splitting it up to a month and a year variable. Here is the complete code:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; data datum;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; Datum = &amp;amp;SYSDATE9;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; Monat = MONTH(Datum);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; Premonat =;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; If Monat = &lt;/SPAN&gt;&lt;SPAN style="color: #800080; font-size: 12pt; font-family: Courier New;"&gt;'1'&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; Premonat = &lt;/SPAN&gt;&lt;SPAN style="color: #800080; font-size: 12pt; font-family: Courier New;"&gt;'12'&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;else&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; Premonat = (Monat-&lt;/SPAN&gt;&lt;SPAN style="; color: #008080; font-size: 12pt; font-family: Courier New;"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; Jahr = YEAR(Datum);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; %let mmyyyy = cat(-,Premonat,Jahr);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="; color: #000080; font-size: 12pt; font-family: Courier New;"&gt;&lt;STRONG&gt; export&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;data&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;=SASUSER.GEBDATUM&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt; outfile&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;= &lt;/SPAN&gt;&lt;SPAN style="color: #800080; font-size: 12pt; font-family: Courier New;"&gt;"X:\filename-&amp;amp;monat&amp;amp;mmyyyy..txt"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt; dbms&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;=tab &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt; replace&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt; Delimiter&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #800080; font-size: 12pt; font-family: Courier New;"&gt;';'&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt; putnames&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;=no;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;Here is the important part of the log: &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE: 9405 records were written to the file 'X:\filename-cat(-,Premonat,Jahr).txt'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So it does know that &amp;amp;mmyyyy is a variable within the code, but it does not transport the logic nor the value behind it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What am I doing wrong here? What can I do to transport the values from the data step to my export procedure?&lt;/P&gt;&lt;P&gt;In the data step output my values are correct (Datum: 20047, Monat: 11, Premonat: 10, Jahr: 2014;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Nov 2014 12:02:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Variable-in-PROC-EXPORT-outfile/m-p/179218#M45756</guid>
      <dc:creator>ins_dev</dc:creator>
      <dc:date>2014-11-20T12:02:31Z</dc:date>
    </item>
    <item>
      <title>Re: Variable in PROC EXPORT outfile</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Variable-in-PROC-EXPORT-outfile/m-p/179219#M45757</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are using the macro statement %let erroneously in the data step. Macro directives (%... statements and &amp;amp;.... variables) are executed by the macro processor BEFORE the data step is compiled and executed.&lt;/P&gt;&lt;P&gt;So you get a macro variable mmyyyy with the value &lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;cat(-,Premonat,Jahr)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;Use call symput instead to export values from a data step into a macro variable.&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Nov 2014 12:19:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Variable-in-PROC-EXPORT-outfile/m-p/179219#M45757</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2014-11-20T12:19:01Z</dc:date>
    </item>
    <item>
      <title>Re: Variable in PROC EXPORT outfile</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Variable-in-PROC-EXPORT-outfile/m-p/179220#M45758</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I like to handle such problems with a data _null_ step:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;datum = intnx('month',date(),-1);&lt;/P&gt;&lt;P&gt;call symput('mmyyyy',put(month(datum),z2.)!!put(year(datum),z4.));&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Nov 2014 12:23:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Variable-in-PROC-EXPORT-outfile/m-p/179220#M45758</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2014-11-20T12:23:43Z</dc:date>
    </item>
    <item>
      <title>Re: Variable in PROC EXPORT outfile</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Variable-in-PROC-EXPORT-outfile/m-p/179221#M45759</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your solution worked perfectly out.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Vielen Dank!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Nov 2014 12:38:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Variable-in-PROC-EXPORT-outfile/m-p/179221#M45759</guid>
      <dc:creator>ins_dev</dc:creator>
      <dc:date>2014-11-20T12:38:43Z</dc:date>
    </item>
  </channel>
</rss>

