<?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: Macro code to export in excel in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-code-to-export-in-excel/m-p/450657#M113497</link>
    <description>like exactly how??&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Tue, 03 Apr 2018 14:25:03 GMT</pubDate>
    <dc:creator>anirudhs</dc:creator>
    <dc:date>2018-04-03T14:25:03Z</dc:date>
    <item>
      <title>Macro code to export in excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-code-to-export-in-excel/m-p/449334#M113074</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;I am looking for a macro code as i have a variable name city and that variable contains 126 names of unique cities,&lt;/P&gt;&lt;P&gt;and want to export the same data set into excel with condition where city='xyz'&lt;/P&gt;&lt;P&gt;and the excel should contain the name of the same city which is used in the condition.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As using the following code for 126 unique cities is not affordable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;e.g.: proc export&lt;BR /&gt;data=WORK.CAPFIRST_ENCOLLEC_MASTER (where=(City='PUNE'))&lt;BR /&gt;dbms=xlsx&lt;BR /&gt;outfile="\\10.4.1.205\Upload\DAC_FINAL_PUNE.xlsx"&lt;BR /&gt;replace;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So looking for macro and looping to export using that macro.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Mar 2018 14:22:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-code-to-export-in-excel/m-p/449334#M113074</guid>
      <dc:creator>anirudhs</dc:creator>
      <dc:date>2018-03-28T14:22:25Z</dc:date>
    </item>
    <item>
      <title>Re: Macro code to export in excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-code-to-export-in-excel/m-p/449341#M113077</link>
      <description>&lt;P&gt;Try using ODS EXCEL instead.&amp;nbsp; You can tell it to make a separate sheet for each BY group.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Mar 2018 14:35:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-code-to-export-in-excel/m-p/449341#M113077</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-03-28T14:35:03Z</dc:date>
    </item>
    <item>
      <title>Re: Macro code to export in excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-code-to-export-in-excel/m-p/449354#M113080</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/106991"&gt;@anirudhs&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi ,&lt;/P&gt;
&lt;P&gt;I am looking for a macro code as i have a variable name city and that variable contains 126 names of unique cities,&lt;/P&gt;
&lt;P&gt;and want to export the same data set into excel with condition where city='xyz'&lt;/P&gt;
&lt;P&gt;and the excel should contain the name of the same city which is used in the condition.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As using the following code for 126 unique cities is not affordable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;e.g.: proc export&lt;BR /&gt;data=WORK.CAPFIRST_ENCOLLEC_MASTER (where=(City='PUNE'))&lt;BR /&gt;dbms=xlsx&lt;BR /&gt;outfile="\\10.4.1.205\Upload\DAC_FINAL_PUNE.xlsx"&lt;BR /&gt;replace;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So looking for macro and looping to export using that macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Are you trying to create a new workbook for each city or a new worksheet for each city?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it's a new worksheet, then use the ODS EXCEL with BY option as indicated by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;If a new workbook, then you would need another option. Rather than a macro, for something this simple, I would recommend Call Execute.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Mar 2018 14:45:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-code-to-export-in-excel/m-p/449354#M113080</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-03-28T14:45:40Z</dc:date>
    </item>
    <item>
      <title>Re: Macro code to export in excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-code-to-export-in-excel/m-p/449414#M113087</link>
      <description>yes i want new work book for each city.&lt;BR /&gt;&lt;BR /&gt;but the code and condition is to be written 126 times... is that fisible ????&lt;BR /&gt;&lt;BR /&gt;to write the proc export code 126 times by just changing the city name in each occurrence of export code</description>
      <pubDate>Wed, 28 Mar 2018 16:05:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-code-to-export-in-excel/m-p/449414#M113087</guid>
      <dc:creator>anirudhs</dc:creator>
      <dc:date>2018-03-28T16:05:47Z</dc:date>
    </item>
    <item>
      <title>Re: Macro code to export in excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-code-to-export-in-excel/m-p/449415#M113088</link>
      <description>&lt;P&gt;You don't really need a macro.&amp;nbsp; You just need to use code generation.&amp;nbsp; Since you a driving the code generation from data it is probably easier to do with a data step.&amp;nbsp; You could use CALL EXECUTE().&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set WORK.CAPFIRST_ENCOLLEC_MASTER ;
  by city;
  if first.city ;
  call execute(catx(' '
,'proc export'
,'data=WORK.CAPFIRST_ENCOLLEC_MASTER dbms=xlsx'
,'outfile=',quote(cats('\\10.4.1.205\Upload\DAC_FINAL_',city,'.xlsx'))
,'replace;'
,'where City=',quote(trim(city)),';'
,'run;'
));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Mar 2018 16:41:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-code-to-export-in-excel/m-p/449415#M113088</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-03-28T16:41:06Z</dc:date>
    </item>
    <item>
      <title>Re: Macro code to export in excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-code-to-export-in-excel/m-p/449417#M113089</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt; I think you're missing the PROC EXPORT text portion.</description>
      <pubDate>Wed, 28 Mar 2018 16:22:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-code-to-export-in-excel/m-p/449417#M113089</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-03-28T16:22:54Z</dc:date>
    </item>
    <item>
      <title>Re: Macro code to export in excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-code-to-export-in-excel/m-p/449418#M113090</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/106991"&gt;@anirudhs&lt;/a&gt; wrote:&lt;BR /&gt;yes i want new work book for each city.&lt;BR /&gt;&lt;BR /&gt;but the code and condition is to be written 126 times... is that fisible ????&lt;BR /&gt;&lt;BR /&gt;to write the proc export code 126 times by just changing the city name in each occurrence of export code&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No one suggested you do that. We asked what you were trying to do, so we can provide a better response.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can make the code be generated automatically, see&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;s answer. A macro would work but it's more code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. First get a list of all citys&lt;/P&gt;
&lt;P&gt;2. Write a macro to export&lt;/P&gt;
&lt;P&gt;3. Call macro for each city using call execute.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Untested below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table distinct_city as
select distinct city from have;
quit;

%macro export_sheet(city=);


proc export data=&amp;amp;have (where=(city="&amp;amp;city")) 
outfile="C:\_localdata\&amp;amp;City..xlsx" dbms=xlsx replace; run;

%mend;

data _null_;
set distinct_city;

str = catt('%export_sheet(city=', city, ');');

call execute (str);

run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Personally, I'd use Tom's solution instead.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Mar 2018 16:28:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-code-to-export-in-excel/m-p/449418#M113090</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-03-28T16:28:30Z</dc:date>
    </item>
    <item>
      <title>Re: Macro code to export in excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-code-to-export-in-excel/m-p/449422#M113092</link>
      <description>Thanks. Updated.&lt;BR /&gt;</description>
      <pubDate>Wed, 28 Mar 2018 16:44:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-code-to-export-in-excel/m-p/449422#M113092</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-03-28T16:44:15Z</dc:date>
    </item>
    <item>
      <title>Re: Macro code to export in excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-code-to-export-in-excel/m-p/449428#M113096</link>
      <description>I will try and test both the codes,&lt;BR /&gt;but i would like to say that the data set contains round about 3 lakhs rows of data with recuring of city names with minimum of 5000 rows.&lt;BR /&gt;&lt;BR /&gt;SO i will update once i test both the code.&lt;BR /&gt;Thanks</description>
      <pubDate>Wed, 28 Mar 2018 16:50:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-code-to-export-in-excel/m-p/449428#M113096</guid>
      <dc:creator>anirudhs</dc:creator>
      <dc:date>2018-03-28T16:50:02Z</dc:date>
    </item>
    <item>
      <title>Re: Macro code to export in excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-code-to-export-in-excel/m-p/449429#M113097</link>
      <description>&lt;P&gt;300K rows is trivial. If it can fit in Excel its not big data &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Mar 2018 16:55:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-code-to-export-in-excel/m-p/449429#M113097</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-03-28T16:55:08Z</dc:date>
    </item>
    <item>
      <title>Re: Macro code to export in excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-code-to-export-in-excel/m-p/450566#M113445</link>
      <description>this is the following error i am getting when used the code you have mentioned&lt;BR /&gt;&lt;BR /&gt;WARNING: Apparent symbolic reference WORK not resolved.&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;NOTE: Line generated by the CALL EXECUTE routine.&lt;BR /&gt;1 + proc export data=&amp;amp;WORK.DAC_3 (where=(city='&amp;amp;city')) outfile="\\10.4.1.205\Upload\DAC_AGRA.xlsx" dbms=xlsx replace;&lt;BR /&gt;run;;&lt;BR /&gt;_&lt;BR /&gt;22&lt;BR /&gt;76&lt;BR /&gt;ERROR 22-322: Expecting a name.&lt;BR /&gt;&lt;BR /&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;BR /&gt;&lt;BR /&gt;please update..</description>
      <pubDate>Tue, 03 Apr 2018 10:51:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-code-to-export-in-excel/m-p/450566#M113445</guid>
      <dc:creator>anirudhs</dc:creator>
      <dc:date>2018-04-03T10:51:10Z</dc:date>
    </item>
    <item>
      <title>Re: Macro code to export in excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-code-to-export-in-excel/m-p/450567#M113446</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt; getting following errors for all cities when testing your code :&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;NOTE: Line generated by the CALL EXECUTE routine.&lt;BR /&gt;89 + data=WORK.DAC_3 dbms=xlsx outfile= "\\10.4.1.205\Upload\DAC_FINAL_YAMUNANAGAR.xlsx" replace;&lt;BR /&gt;____&lt;BR /&gt;180&lt;BR /&gt;&lt;BR /&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.</description>
      <pubDate>Tue, 03 Apr 2018 10:53:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-code-to-export-in-excel/m-p/450567#M113446</guid>
      <dc:creator>anirudhs</dc:creator>
      <dc:date>2018-04-03T10:53:58Z</dc:date>
    </item>
    <item>
      <title>Re: Macro code to export in excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-code-to-export-in-excel/m-p/450616#M113470</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/106991"&gt;@anirudhs&lt;/a&gt; wrote:&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt; getting following errors for all cities when testing your code :&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;NOTE: Line generated by the CALL EXECUTE routine.&lt;BR /&gt;89 + data=WORK.DAC_3 dbms=xlsx outfile= "\\10.4.1.205\Upload\DAC_FINAL_YAMUNANAGAR.xlsx" replace;&lt;BR /&gt;____&lt;BR /&gt;180&lt;BR /&gt;&lt;BR /&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Most likely you have a missing or extra semi-colon.&amp;nbsp; Would need to see the whole log to debug, but you should be able to debug on your own.&amp;nbsp; Get the syntax for one proc step right and working and then make sure the data step is generating the same syntax.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Apr 2018 13:17:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-code-to-export-in-excel/m-p/450616#M113470</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-04-03T13:17:17Z</dc:date>
    </item>
    <item>
      <title>Re: Macro code to export in excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-code-to-export-in-excel/m-p/450621#M113473</link>
      <description>Yeh found it, and is running but taking too long time to execute.</description>
      <pubDate>Tue, 03 Apr 2018 13:24:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-code-to-export-in-excel/m-p/450621#M113473</guid>
      <dc:creator>anirudhs</dc:creator>
      <dc:date>2018-04-03T13:24:37Z</dc:date>
    </item>
    <item>
      <title>Re: Macro code to export in excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-code-to-export-in-excel/m-p/450627#M113477</link>
      <description>&lt;P&gt;How many XLSX files are you generating?&lt;/P&gt;
&lt;P&gt;Why are you generating so many XLSX files?&lt;/P&gt;</description>
      <pubDate>Tue, 03 Apr 2018 13:34:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-code-to-export-in-excel/m-p/450627#M113477</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-04-03T13:34:27Z</dc:date>
    </item>
    <item>
      <title>Re: Macro code to export in excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-code-to-export-in-excel/m-p/450628#M113478</link>
      <description>Extremely sorry to update you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt; the code you send is working but it is exporting the xlsx city but those excel contains data of all the cities,&lt;BR /&gt;requirement is that the excel should only contain data with the city names.&lt;BR /&gt;i.e. if data set contains 500 records of city pune then the excel DAC_Final_Pune.xlsx will have those 500 records from the data set only.</description>
      <pubDate>Tue, 03 Apr 2018 13:35:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-code-to-export-in-excel/m-p/450628#M113478</guid>
      <dc:creator>anirudhs</dc:creator>
      <dc:date>2018-04-03T13:35:52Z</dc:date>
    </item>
    <item>
      <title>Re: Macro code to export in excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-code-to-export-in-excel/m-p/450635#M113482</link>
      <description>&lt;P&gt;So PROC EXPORT does not support the WHERE statement?&lt;BR /&gt;Did you try converting to using WHERE= dataset option on the input data set?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try&amp;nbsp;it for one city value to see if it works.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you cannot get PROC EXPORT to honor the WHERE then you could add a data step to create the subset and then export that new dataset.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Apr 2018 13:50:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-code-to-export-in-excel/m-p/450635#M113482</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-04-03T13:50:43Z</dc:date>
    </item>
    <item>
      <title>Re: Macro code to export in excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-code-to-export-in-excel/m-p/450644#M113487</link>
      <description>This code for export works fine:&lt;BR /&gt;proc export&lt;BR /&gt;data=WORK.DAC_3 (where=(City='MUMBAI'))&lt;BR /&gt;dbms=xlsx&lt;BR /&gt;outfile="\\10.4.1.205\Upload\DAC_FINAL_MUMBAI.xlsx"&lt;BR /&gt;replace;&lt;BR /&gt;run;</description>
      <pubDate>Tue, 03 Apr 2018 14:16:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-code-to-export-in-excel/m-p/450644#M113487</guid>
      <dc:creator>anirudhs</dc:creator>
      <dc:date>2018-04-03T14:16:47Z</dc:date>
    </item>
    <item>
      <title>Re: Macro code to export in excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-code-to-export-in-excel/m-p/450648#M113490</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;:&lt;/P&gt;&lt;P&gt;Your macro code also is giving error, mentioned&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: PROCEDURE EXPORT used (Total process time):&lt;BR /&gt;real time 0.00 seconds&lt;BR /&gt;cpu time 0.00 seconds&lt;BR /&gt;&lt;BR /&gt;WARNING: Apparent symbolic reference WORK not resolved.&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;NOTE: Line generated by the CALL EXECUTE routine.&lt;BR /&gt;90 + proc export data=&amp;amp;WORK.DAC_3 (where=(city="ZIRAKPUR")) outfile="\\10.4.1.205\Upload\DAC_FINAL_ZIRAKPUR.xlsx" dbms=xlsx&lt;BR /&gt;_&lt;BR /&gt;22&lt;BR /&gt;76&lt;BR /&gt;90 !+replace; run;;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;ERROR 22-322: Expecting a name.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Apr 2018 14:20:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-code-to-export-in-excel/m-p/450648#M113490</guid>
      <dc:creator>anirudhs</dc:creator>
      <dc:date>2018-04-03T14:20:24Z</dc:date>
    </item>
    <item>
      <title>Re: Macro code to export in excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-code-to-export-in-excel/m-p/450650#M113492</link>
      <description>&lt;P&gt;Then just modify&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;'s code to use the where datastep option like you showed in your example. i.e.:&lt;/P&gt;
&lt;PRE&gt;proc sort data=WORK.CAPFIRST_ENCOLLEC_MASTER;
  by city;
run;

data _null_;
  set WORK.CAPFIRST_ENCOLLEC_MASTER ;
  by city;
  if first.city ;
  call execute(catx(' '
   ,'proc export'
   ,'data=WORK.CAPFIRST_ENCOLLEC_MASTER (where=(city ='
   ,quote(trim(city))
   ,')) dbms=xlsx'
   ,'outfile=',quote(cats('\\10.4.1.205\Upload\DAC_FINAL_',city,'.xlsx'))
   ,'replace;'
   ,'run;'
   ));
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Apr 2018 14:21:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-code-to-export-in-excel/m-p/450650#M113492</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-04-03T14:21:31Z</dc:date>
    </item>
  </channel>
</rss>

