<?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 macro in ODS  excel File name in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Using-macro-in-ODS-excel-File-name/m-p/684282#M24466</link>
    <description>&lt;P&gt;Thank you! I will try it!&lt;/P&gt;</description>
    <pubDate>Wed, 16 Sep 2020 15:27:11 GMT</pubDate>
    <dc:creator>MCB1</dc:creator>
    <dc:date>2020-09-16T15:27:11Z</dc:date>
    <item>
      <title>Using macro in ODS  excel File name</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Using-macro-in-ODS-excel-File-name/m-p/684267#M24463</link>
      <description>&lt;P&gt;I need to export a simple SAS table to Excel and later on import it back to SAS. I need to do it multiple times (several years). The result expected is 4 Excel files and 4 SAS files. The macro is not working well in creating&amp;nbsp;the Excel files.&lt;/P&gt;&lt;P&gt;best regard&lt;/P&gt;&lt;P&gt;MCB1&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code:&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; bilar(ar);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;ODS excel FILE=&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;'\\micro.intra\projekt\P0069_ESV$\Marcela\Bilar\OUTPUT\BESK_BILARX&amp;amp;ar.XLSX'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;PROC FREQ DATA=G.BILAR&amp;amp;ar ;&lt;/P&gt;&lt;P&gt;TABLES BILMODELL*BESKRIVNING*PRIS/LIST MISSING ;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;ODS EXCEL CLOSE;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC IMPORT OUT= BESK_MODELLER&amp;amp;ar&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;DATAFILE= &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;"\\micro.intra\Projekt\P0069_ESV$\Marcela\Bilar\OUTPUT\BESK_BILAR2X&amp;amp;ar.XLSX"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;DBMS=EXCEL REPLACE;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;RANGE=&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;"'Freq 1 - LIST Frequencies$'"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;GETNAMES=YES;&lt;/P&gt;&lt;P&gt;MIXED=NO;&lt;/P&gt;&lt;P&gt;SCANTEXT=YES;&lt;/P&gt;&lt;P&gt;USEDATE=YES;&lt;/P&gt;&lt;P&gt;SCANTIME=YES;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;%&lt;STRONG&gt;&lt;I&gt;bilar&lt;/I&gt;&lt;/STRONG&gt;(&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;2016&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;%&lt;STRONG&gt;&lt;I&gt;bilar&lt;/I&gt;&lt;/STRONG&gt;(&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;2017&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;%&lt;STRONG&gt;&lt;I&gt;bilar&lt;/I&gt;&lt;/STRONG&gt;(&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;2018&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;%&lt;STRONG&gt;&lt;I&gt;bilar&lt;/I&gt;&lt;/STRONG&gt;(&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;2019&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Sep 2020 15:12:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Using-macro-in-ODS-excel-File-name/m-p/684267#M24463</guid>
      <dc:creator>MCB1</dc:creator>
      <dc:date>2020-09-16T15:12:03Z</dc:date>
    </item>
    <item>
      <title>Re: Using macro in ODS  excel File name</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Using-macro-in-ODS-excel-File-name/m-p/684272#M24464</link>
      <description>&lt;P&gt;Macro variables will not resolve inside single quotes.&amp;nbsp; Change them to double quotes in the ODS statement:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;ODS excel FILE="\\micro.intra\projekt\P0069_ESV$\Marcela\Bilar\OUTPUT\BESK_BILARX&amp;amp;ar.XLSX";&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Sep 2020 15:16:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Using-macro-in-ODS-excel-File-name/m-p/684272#M24464</guid>
      <dc:creator>CurtisMackWSIPP</dc:creator>
      <dc:date>2020-09-16T15:16:08Z</dc:date>
    </item>
    <item>
      <title>Re: Using macro in ODS  excel File name</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Using-macro-in-ODS-excel-File-name/m-p/684280#M24465</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/339357"&gt;@CurtisMackWSIPP&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Macro variables will not resolve inside single quotes.&amp;nbsp; Change them to double quotes in the ODS statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;ODS excel FILE="\\micro.intra\projekt\P0069_ESV$\Marcela\Bilar\OUTPUT\BESK_BILARX&amp;amp;ar.XLSX";&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;And since the dot character is the macro language concatenation symbol you will need two .. before the extension.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ODS excel FILE="\\micro.intra\projekt\P0069_ESV$\Marcela\Bilar\OUTPUT\BESK_BILARX&amp;amp;ar..XLSX";&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Sep 2020 15:26:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Using-macro-in-ODS-excel-File-name/m-p/684280#M24465</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-09-16T15:26:25Z</dc:date>
    </item>
    <item>
      <title>Re: Using macro in ODS  excel File name</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Using-macro-in-ODS-excel-File-name/m-p/684282#M24466</link>
      <description>&lt;P&gt;Thank you! I will try it!&lt;/P&gt;</description>
      <pubDate>Wed, 16 Sep 2020 15:27:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Using-macro-in-ODS-excel-File-name/m-p/684282#M24466</guid>
      <dc:creator>MCB1</dc:creator>
      <dc:date>2020-09-16T15:27:11Z</dc:date>
    </item>
    <item>
      <title>Re: Using macro in ODS  excel File name</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Using-macro-in-ODS-excel-File-name/m-p/684291#M24467</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;It looks like your goal is to get the output from PROC FREQ into a SAS dataset, is that right?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You shouldn't have to write to Excel and read it back in, to do that.&amp;nbsp; In general, I tried to avoid Excel whenever possible. : )&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You should be able to use the output delivery system (ODS) to write SAS data sets directly, e.g.:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods output list=mylist ;
proc freq data=sashelp.prdsale ;
  tables region*division*product*prodtype /missing list;
run ;
ods output close ;

proc print data=mylist ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you keep it all in SAS, you don't need to worry about losing precision, or having problems with SAS or Excel making bad guesses as to variable types.&amp;nbsp; ODS gives you a way to create datasets with the same information you see in the SAS output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The scariest comment I ever saw in some code was "At this point, I exported the data into Excel and then made some fixes and read it back into SAS."&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Sep 2020 15:42:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Using-macro-in-ODS-excel-File-name/m-p/684291#M24467</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2020-09-16T15:42:08Z</dc:date>
    </item>
    <item>
      <title>Re: Using macro in ODS  excel File name</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Using-macro-in-ODS-excel-File-name/m-p/684292#M24468</link>
      <description>Thanks! this works very well!</description>
      <pubDate>Wed, 16 Sep 2020 15:44:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Using-macro-in-ODS-excel-File-name/m-p/684292#M24468</guid>
      <dc:creator>MCB1</dc:creator>
      <dc:date>2020-09-16T15:44:03Z</dc:date>
    </item>
    <item>
      <title>Re: Using macro in ODS  excel File name</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Using-macro-in-ODS-excel-File-name/m-p/684305#M24469</link>
      <description>Thank you Quentin! I try to avoid Excel as well. In this case I needed to create 2 variables based on information from a description (multiple strings). In my example the column "beskrivning". In Excel I can look for this particular information and create the variables in a very simple way by writing the Word or words I am looking for using the filter and later on importing it back to SAS.</description>
      <pubDate>Wed, 16 Sep 2020 16:18:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Using-macro-in-ODS-excel-File-name/m-p/684305#M24469</guid>
      <dc:creator>MCB1</dc:creator>
      <dc:date>2020-09-16T16:18:17Z</dc:date>
    </item>
  </channel>
</rss>

