<?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 Iteration by PROC APPEND takes a long time. in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Iteration-by-PROC-APPEND-takes-a-long-time/m-p/36065#M9044</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Tom;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your kindly response ! &lt;/P&gt;&lt;P&gt;I've got your advice by executing.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sincerely,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 26 Jul 2011 03:19:40 GMT</pubDate>
    <dc:creator>pofu</dc:creator>
    <dc:date>2011-07-26T03:19:40Z</dc:date>
    <item>
      <title>Iteration by PROC APPEND takes a long time.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Iteration-by-PROC-APPEND-takes-a-long-time/m-p/36062#M9041</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello. I intend to get a dataset by appending many outputs of PROC FREQ with each variables and the outcome. &lt;/P&gt;&lt;P&gt;Although the number of iteraition is about 50,000, it takes half a day. &lt;/P&gt;&lt;P&gt;Could you tell me the better way for calculating faster ? &lt;/P&gt;&lt;P&gt;I appreciate your kindness helping. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The program is as following:&amp;nbsp; &lt;/P&gt;&lt;P&gt;////////////////////////////////////////////////////// &lt;/P&gt;&lt;P&gt;%macro outtest(outcome=); &lt;/P&gt;&lt;P&gt;*; &lt;/P&gt;&lt;P&gt;%let dsid=%sysfunc(open(a1,i)); &lt;/P&gt;&lt;P&gt;%let vnum=%sysfunc(attrn(&amp;amp;dsid,nvars)); &lt;/P&gt;&lt;P&gt;%let rc=%sysfunc(close(&amp;amp;dsid)); &lt;/P&gt;&lt;P&gt;*; &lt;/P&gt;&lt;P&gt;*; &lt;/P&gt;&lt;P&gt;%do no=1 %to &amp;amp;vnum; &lt;/P&gt;&lt;P&gt;proc freq data=a1 noprint; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; output out=nout&amp;amp;no trend exact; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; tables &amp;amp;outcome*numgeno&amp;amp;no / exact trend; &lt;/P&gt;&lt;P&gt;run; &lt;/P&gt;&lt;P&gt;%end; &lt;/P&gt;&lt;P&gt;*; &lt;/P&gt;&lt;P&gt;data n1; &lt;/P&gt;&lt;P&gt;&amp;nbsp; set nout1; &lt;/P&gt;&lt;P&gt;run; &lt;/P&gt;&lt;P&gt;*; &lt;/P&gt;&lt;P&gt;%do no=2 %to &amp;amp;vnum; &lt;/P&gt;&lt;P&gt;proc append base=n1 data=nout&amp;amp;no force; &lt;/P&gt;&lt;P&gt;run; &lt;/P&gt;&lt;P&gt;%end; &lt;/P&gt;&lt;P&gt;*; &lt;/P&gt;&lt;P&gt;%mend; &lt;/P&gt;&lt;P&gt;*; &lt;/P&gt;&lt;P&gt;%outtest(outcome=COL1D); &lt;/P&gt;&lt;P&gt;////////////////////////////////////////////////////// &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards, &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Jul 2011 06:20:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Iteration-by-PROC-APPEND-takes-a-long-time/m-p/36062#M9041</guid>
      <dc:creator>pofu</dc:creator>
      <dc:date>2011-07-25T06:20:04Z</dc:date>
    </item>
    <item>
      <title>Iteration by PROC APPEND takes a long time.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Iteration-by-PROC-APPEND-takes-a-long-time/m-p/36063#M9042</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I suspect that it is the EXACT statistics request that is taking a long time. You can look at your SAS log and see how long each step takes to confirm.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not sure why you are using a macro and looping through the variables.&amp;nbsp; &lt;/P&gt;&lt;P&gt;Why not just tell SAS to do them all at once?&amp;nbsp; Your macro is assuming that you have variables named NUMGENO1 to NUMGENO&amp;amp;n where &amp;amp;N is the number of variables in the dataset. (not sure how that is possible if you also have a variable named COL1D in the dataset.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc freq data=a1 noprint;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; output out=n1 trend exact;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; tables &amp;amp;outcome*(numgeno1 - numgeno&amp;amp;vnum) / exact trend;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Jul 2011 13:33:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Iteration-by-PROC-APPEND-takes-a-long-time/m-p/36063#M9042</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2011-07-25T13:33:03Z</dc:date>
    </item>
    <item>
      <title>Iteration by PROC APPEND takes a long time.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Iteration-by-PROC-APPEND-takes-a-long-time/m-p/36064#M9043</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; You have 50,000 variables?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't doubt your program takes a very long to run, partly due to the statistics you request but you still should be able to do it.&amp;nbsp; Macro looping over 50,000 variables in a receipt for disaster. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You don't need to call PROC FREQ over and over.&amp;nbsp; It will work for many(all) variables from a data set in one step, and produce output in this case two files one for Exact another for Trend.&amp;nbsp; No need for macro loops or PROC APPEND.&amp;nbsp;&amp;nbsp; I have never tried 50,000 variables so you may run into some problem there.&amp;nbsp; If that happens you could try using a few lists&amp;nbsp; &lt;/P&gt;&lt;P&gt;NUMGENO1-NUMGENO10000&lt;/P&gt;&lt;P&gt;NUMGENO10001-NUMGENO20000&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;a least you are not calling FREQ/APPEND 50,000 times.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use the example below to modify your program to work without macro loops that you don't need.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;ods&lt;/SPAN&gt; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;listing&lt;/SPAN&gt; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;close&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;ods&lt;/SPAN&gt; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;output&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; FishersExact=FishersExact TrendTest=TrendTest;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;freq&lt;/STRONG&gt; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;data&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;=sashelp.class; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;tables&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; sex*(_all_) / exact &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;trend&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;ods output close;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;ods&lt;/SPAN&gt; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;listing&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;print&lt;/STRONG&gt; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;data&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;=FishersExact;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;print&lt;/STRONG&gt; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;data&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;=TrendTest;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Jul 2011 13:36:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Iteration-by-PROC-APPEND-takes-a-long-time/m-p/36064#M9043</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2011-07-25T13:36:33Z</dc:date>
    </item>
    <item>
      <title>Iteration by PROC APPEND takes a long time.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Iteration-by-PROC-APPEND-takes-a-long-time/m-p/36065#M9044</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Tom;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your kindly response ! &lt;/P&gt;&lt;P&gt;I've got your advice by executing.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sincerely,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jul 2011 03:19:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Iteration-by-PROC-APPEND-takes-a-long-time/m-p/36065#M9044</guid>
      <dc:creator>pofu</dc:creator>
      <dc:date>2011-07-26T03:19:40Z</dc:date>
    </item>
    <item>
      <title>Iteration by PROC APPEND takes a long time.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Iteration-by-PROC-APPEND-takes-a-long-time/m-p/36066#M9045</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear data_null_;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your kindly response ! &lt;/P&gt;&lt;P&gt;I've got your advice by executing it.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sincerely,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jul 2011 03:21:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Iteration-by-PROC-APPEND-takes-a-long-time/m-p/36066#M9045</guid>
      <dc:creator>pofu</dc:creator>
      <dc:date>2011-07-26T03:21:12Z</dc:date>
    </item>
  </channel>
</rss>

