<?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 PROC EXPORT stalls in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-stalls/m-p/815007#M321709</link>
    <description>&lt;P&gt;I have the following program, which runs fine until it gets to the 3rd export file (Toexport3) and any other files after that.&amp;nbsp; It exports Toexport1 and Toexport2 and creates the resulting excel files for both, but stalls at Toexport3.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;DATA A; INFILE 'C:\Users\ra\Documents\My SAS Files\SAS 9.4 Data\text\pdt_output_trimmed.txt' 
	TRUNCOVER FIRSTOBS = 2;
input	@1	NIIN $9.	
	@11	PLANT $4.	
	@16     SLOC $4.	
	@20     PDT $3.	
;
RUN;

DATA B; SET A; if PLANT = '2001';
	RENAME NIIN = niin PLANT = plant SLOC = sloc PDT = replen2;
	PROC SORT DATA = B; BY sloc NIIN;
RUN;

proc freq data=B;
  tables sloc / noprint out=counts ;
run;

data groups;
   if eof then call symputx('ngroups',group);
   set counts end=eof;
   retain group 0 running_count 0;
   if count + running_count &amp;gt; 500000 then do;
      group+1;
      running_count=0;
   end;
   running_count+count;
run;


%macro rep();
  %do i=1 %to &amp;amp;ngroups.;
  	data grp;
  		 set groups;
  		 if group=&amp;amp;i;
 
  		 proc sort data=b;
  		 	 by sloc;
  		 proc sort data=grp;
  		 	by sloc;
  		 	
  		 	data toexport&amp;amp;i;
  		 		merge b(in=a) grp(keep=sloc in=b);
  		 		by sloc;
  		 		if a and b;
  
       proc export data=toexport&amp;amp;i 
       	outfile="C:\Users\ra\Documents\My SAS Files\SAS 9.4 Output\pdt_input&amp;amp;i..xlsx"
       	dbms=xlsx;
  
%end; 	

%mend;

%rep;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Why would the PROC EXPORT execute through the first two outputs but stall at the 3rd and any subsequent files after that?&amp;nbsp; There are 1.9M records in the input file, I'm only getting 1.4M out (up to the point where it stalls).&amp;nbsp; The export data must be in excel due to the requirements of the system it is going into.&lt;/P&gt;&lt;P&gt;Any assistance is greatly appreciated.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 25 May 2022 12:42:17 GMT</pubDate>
    <dc:creator>arbnmedic33</dc:creator>
    <dc:date>2022-05-25T12:42:17Z</dc:date>
    <item>
      <title>PROC EXPORT stalls</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-stalls/m-p/815007#M321709</link>
      <description>&lt;P&gt;I have the following program, which runs fine until it gets to the 3rd export file (Toexport3) and any other files after that.&amp;nbsp; It exports Toexport1 and Toexport2 and creates the resulting excel files for both, but stalls at Toexport3.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;DATA A; INFILE 'C:\Users\ra\Documents\My SAS Files\SAS 9.4 Data\text\pdt_output_trimmed.txt' 
	TRUNCOVER FIRSTOBS = 2;
input	@1	NIIN $9.	
	@11	PLANT $4.	
	@16     SLOC $4.	
	@20     PDT $3.	
;
RUN;

DATA B; SET A; if PLANT = '2001';
	RENAME NIIN = niin PLANT = plant SLOC = sloc PDT = replen2;
	PROC SORT DATA = B; BY sloc NIIN;
RUN;

proc freq data=B;
  tables sloc / noprint out=counts ;
run;

data groups;
   if eof then call symputx('ngroups',group);
   set counts end=eof;
   retain group 0 running_count 0;
   if count + running_count &amp;gt; 500000 then do;
      group+1;
      running_count=0;
   end;
   running_count+count;
run;


%macro rep();
  %do i=1 %to &amp;amp;ngroups.;
  	data grp;
  		 set groups;
  		 if group=&amp;amp;i;
 
  		 proc sort data=b;
  		 	 by sloc;
  		 proc sort data=grp;
  		 	by sloc;
  		 	
  		 	data toexport&amp;amp;i;
  		 		merge b(in=a) grp(keep=sloc in=b);
  		 		by sloc;
  		 		if a and b;
  
       proc export data=toexport&amp;amp;i 
       	outfile="C:\Users\ra\Documents\My SAS Files\SAS 9.4 Output\pdt_input&amp;amp;i..xlsx"
       	dbms=xlsx;
  
%end; 	

%mend;

%rep;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Why would the PROC EXPORT execute through the first two outputs but stall at the 3rd and any subsequent files after that?&amp;nbsp; There are 1.9M records in the input file, I'm only getting 1.4M out (up to the point where it stalls).&amp;nbsp; The export data must be in excel due to the requirements of the system it is going into.&lt;/P&gt;&lt;P&gt;Any assistance is greatly appreciated.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2022 12:42:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-stalls/m-p/815007#M321709</guid>
      <dc:creator>arbnmedic33</dc:creator>
      <dc:date>2022-05-25T12:42:17Z</dc:date>
    </item>
    <item>
      <title>Re: PROC EXPORT stalls</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-stalls/m-p/815009#M321711</link>
      <description>&lt;P&gt;Are you sure it is not just waiting for you to submit the RUN; statement to mark the end of the second PROC EXPORT step?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You seem to have inserted an unneeded RUN: statement after your first DATA step, but left off the RUN: statement from some other steps in your code.&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2022 12:51:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-stalls/m-p/815009#M321711</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-05-25T12:51:05Z</dc:date>
    </item>
    <item>
      <title>Re: PROC EXPORT stalls</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-stalls/m-p/815015#M321714</link>
      <description>Occam strikes again...added a RUN; at the end of the macro, prior to the %end.&lt;BR /&gt;Fixed...thanks.&lt;BR /&gt;&lt;BR /&gt;Bob</description>
      <pubDate>Wed, 25 May 2022 13:04:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-stalls/m-p/815015#M321714</guid>
      <dc:creator>arbnmedic33</dc:creator>
      <dc:date>2022-05-25T13:04:00Z</dc:date>
    </item>
  </channel>
</rss>

