BookmarkSubscribeRSS Feed
Crubal
Quartz | Level 8

I have a SAS macro part that will run the entire dataset and do some analysis, and during the analysis part, each instance is dealt with once a time.so that the entire dataset can be run and we could keep an eye on the 'log' file.

However, I would like to split the entire dataset into several parts. (Ex, first 500 observations, 501~1000 observations, etc). Which means the engine will stop after running 500 instances, and then run again. And in the end they can be generated in one table as before. How can I add this 'split' part into my prior code?

Initial Code:

%macro mymac;
OPTIONS NOTES SOURCE SOURCE2 MPRINT MLOGIC MERROR SYMBOLGEN;

/* Part A starts*/

data _null_;
set WORK.LOCATION end=last;
if last then call symput('nfiles',_n_);
run;

%do i=1 %to &nfiles;

data _null_;
set oriework.PO_LOC;
if &i=_n_ then call symput('code',LOCATION_ID);
run;

/* Part A ends */

%put &code;

proc sql;

create table WORK.pt as select
......

quit;

%if %sysfunc(exist(WORK.result)) %then %do;
data WORK.result;
set WORK.result WORK.pt;
run;
%end;
%else %do;
data WORK.result;
set WORK.pt;
run;
%end;


%end;

%mend;

%mymac;

 

Where 'WORK.LOCATION' is the dataset that I call in 'proc sql' procedure that contains all the 'LOCATION_ID" information that I need.

Part A is where Macro works that it runs from start to the end; can I replace it with a data splitting procedure so that every 500 observations are run altogether and finally combined to one table?

 

Thank you!

2 REPLIES 2
anoopmohandas7
Quartz | Level 8

Crubal,

 

So you wanted your program to take first 500 then process it write output and then process nextn 500 process it and add that to the first batch. This way your program runs for each batch having 500 records and when it completes it appends all the output into one file which would your output.

 

~Anoop

Crubal
Quartz | Level 8

That sounds great! Thanks!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 1163 views
  • 0 likes
  • 2 in conversation