BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
arbnmedic33
Calcite | Level 5

I have the following program, which runs fine until it gets to the 3rd export file (Toexport3) and any other files after that.  It exports Toexport1 and Toexport2 and creates the resulting excel files for both, but stalls at Toexport3. 

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 > 500000 then do;
      group+1;
      running_count=0;
   end;
   running_count+count;
run;


%macro rep();
  %do i=1 %to &ngroups.;
  	data grp;
  		 set groups;
  		 if group=&i;
 
  		 proc sort data=b;
  		 	 by sloc;
  		 proc sort data=grp;
  		 	by sloc;
  		 	
  		 	data toexport&i;
  		 		merge b(in=a) grp(keep=sloc in=b);
  		 		by sloc;
  		 		if a and b;
  
       proc export data=toexport&i 
       	outfile="C:\Users\ra\Documents\My SAS Files\SAS 9.4 Output\pdt_input&i..xlsx"
       	dbms=xlsx;
  
%end; 	

%mend;

%rep;

Why would the PROC EXPORT execute through the first two outputs but stall at the 3rd and any subsequent files after that?  There are 1.9M records in the input file, I'm only getting 1.4M out (up to the point where it stalls).  The export data must be in excel due to the requirements of the system it is going into.

Any assistance is greatly appreciated. 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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?

 

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.

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

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?

 

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.

arbnmedic33
Calcite | Level 5
Occam strikes again...added a RUN; at the end of the macro, prior to the %end.
Fixed...thanks.

Bob

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 299 views
  • 1 like
  • 2 in conversation