<?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 Using a proc freq output as a selection criteria for an export macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-a-proc-freq-output-as-a-selection-criteria-for-an-export/m-p/475235#M285973</link>
    <description>&lt;P&gt;I need to take a variable created by the output of a proc freq and use it to iterate and select several proc export files. The point is to automate a selection and output criteria.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using the following generates 28 unique rows.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; proc freq data=MatchedLeads;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; tables campaigngroup_name / out=OutFreq(rename=(campaigngroup_name=Selector)keep=campaigngroup_name) ;&lt;BR /&gt;&amp;nbsp; run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now I want to take the 28 observation, one variable (Selector) and use it to create an iterative process that will create 28 separate export files.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Currently my proc export code looks like this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;proc export data= MatchedLeads outfile="\\sysdir\exportdatamatched.xlsx"&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;dbms=xlsx replace;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This just gives me one huge data set. I need it to select and export based on the results from the freq above.&lt;/P&gt;</description>
    <pubDate>Tue, 03 Jul 2018 15:39:03 GMT</pubDate>
    <dc:creator>CarterM</dc:creator>
    <dc:date>2018-07-03T15:39:03Z</dc:date>
    <item>
      <title>Using a proc freq output as a selection criteria for an export macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-proc-freq-output-as-a-selection-criteria-for-an-export/m-p/475235#M285973</link>
      <description>&lt;P&gt;I need to take a variable created by the output of a proc freq and use it to iterate and select several proc export files. The point is to automate a selection and output criteria.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using the following generates 28 unique rows.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; proc freq data=MatchedLeads;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; tables campaigngroup_name / out=OutFreq(rename=(campaigngroup_name=Selector)keep=campaigngroup_name) ;&lt;BR /&gt;&amp;nbsp; run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now I want to take the 28 observation, one variable (Selector) and use it to create an iterative process that will create 28 separate export files.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Currently my proc export code looks like this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;proc export data= MatchedLeads outfile="\\sysdir\exportdatamatched.xlsx"&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;dbms=xlsx replace;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This just gives me one huge data set. I need it to select and export based on the results from the freq above.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Jul 2018 15:39:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-proc-freq-output-as-a-selection-criteria-for-an-export/m-p/475235#M285973</guid>
      <dc:creator>CarterM</dc:creator>
      <dc:date>2018-07-03T15:39:03Z</dc:date>
    </item>
    <item>
      <title>Re: Using a proc freq output as a selection criteria for an export macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-proc-freq-output-as-a-selection-criteria-for-an-export/m-p/475236#M285974</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;I need it to select and export based on the results from the freq above.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I don't understand this, how you export based on the 28 rows from PROC FREQ. Please explain in detail.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Jul 2018 15:41:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-proc-freq-output-as-a-selection-criteria-for-an-export/m-p/475236#M285974</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-07-03T15:41:59Z</dc:date>
    </item>
    <item>
      <title>Re: Using a proc freq output as a selection criteria for an export macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-proc-freq-output-as-a-selection-criteria-for-an-export/m-p/475241#M285975</link>
      <description>&lt;P&gt;I am going to presume call execute:&lt;/P&gt;
&lt;PRE&gt;proc freq data=MatchedLeads;
  tables campaigngroup_name / out=OutFreq (rename=(campaigngroup_name=Selector) keep=campaigngroup_name) ;
run;

data _null_;
  set outfreq;
  call execute('proc export data= MatchedLeads outfile="\\sysdir\exportdatamatched.xlsx"
                  dbms=xlsx replace;
                run;');
run;

 &lt;/PRE&gt;
&lt;P&gt;This will create one export statement for each row in the freq output, you will need to add your filters.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Jul 2018 15:56:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-proc-freq-output-as-a-selection-criteria-for-an-export/m-p/475241#M285975</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-07-03T15:56:59Z</dc:date>
    </item>
    <item>
      <title>Re: Using a proc freq output as a selection criteria for an export macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-proc-freq-output-as-a-selection-criteria-for-an-export/m-p/475249#M285976</link>
      <description>&lt;P&gt;I think this is headed in the right direction with CALL EXECUTE.&amp;nbsp; I imagine the final destination is more like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=MatchedLeads;
  tables campaigngroup_name / out=OutFreq (rename=(campaigngroup_name=Selector) keep=campaigngroup_name) ;
run;

data _null_;
  set outfreq;
  call execute('data subset; set MatchedLeads;');
  call execute('where campaigngroup="' || selector || '"; run;');
  call execute('proc export data=subset outfile=');
  call execute('"\\sysdir\' || trim(selector) || '.xlsx" dbms=xlsx replace; run;');
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Jul 2018 16:32:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-proc-freq-output-as-a-selection-criteria-for-an-export/m-p/475249#M285976</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-07-03T16:32:06Z</dc:date>
    </item>
  </channel>
</rss>

