The values of those 5 columns/variables are stored in macro variables, and used in the TEMP TABLE and append step.
I dont think SAS EG is the reason. I use SAS EG on Grid and it works fine for me ..
I am curious as to why you are processing 1 Row at a time and how many Rows do you have in the table ...
Depending on your answer i cud tell if it could be written better way.
i do similar macro based fetch when i have to fetch from Oracle, But i always do it in sets of 1000 at a time
It's curious that you are using 600 steps instead of 2 steps, and then wondering about why the program takes so long.
You only posted the idea of what the program should do, so here's the idea of how to fix it:
data subset_a;
set tablea (obs=200 keep=VarThatINeed);
ordervar = _n_;
run;
proc sql;
create table want as select a.*, b.* from subset_a a, temp b
order by ordervar;
quit;
This whole macro
%MACRO MacroProgram;
%let i=1;
data TableWant;Lenght Variable1 $200;run;
%DO %WHILE (&i<150);
data _null_;
set TableA;
if _N_=&i then
call symput('MacroVariable',SomeVariableFromTableA)
run;
data TEMP;
VariableTableTemp=&Macrovariable;
run;
Proc Append base=TableWant data=TEMP;
is identical to this step
data TableWant ; set TableA (obs=150 keep=SomeVariableFromTableA); VariableTableTemp=SomeVariableFromTableA; run;
This does not represent your processing I suppose, but do reduce the number of steps to speed up the process.
new user don't really understand KISS. Keep It Simple Stupid.
@VDD We've all been there!
In fact I use information of TABLEA conditionally on some information present in TABLEB.
This information from TABLEA is then transformed using TABLEB information a stored in a TEMP Table at each stage of the loop, that is then append to a FINALTABLE.
The only way i found to do that is using macrovariables to keep information in memory when going from one table to the other, does this seems correct for you ?
@Hugo_B wrote:
In fact I use information of TABLEA conditionally on some information present in TABLEB.
This information from TABLEA is then transformed using TABLEB information a stored in a TEMP Table at each stage of the loop, that is then append to a FINALTABLE.
You need to tell us EXACTLY what you are trying to do.
That description above is way too vague for us to help you. And we're on the 3rd PAGE of this thread!!!
I suspect you don't need macro. And even if you did, your original approach would be incredibly slow. Orders of magnitude slower than a data step.
The only way i found to do that is using macrovariables to keep information in memory when going from one table to the other, does this seems correct for you ?
No it does not.
unless you are doing a PROC HTTP and JSON lib i cant think of scenario where you want to process 1 record at a time in SAS.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.