I am not sure what I am doing wrong here, its a very simple example just for me to understand why its giving me an error
%let nc = 1;
data _null_;
do nc = 1 to 10;
proc datasets lib=work kill memtype=data;
end;
run;
This gives me the following error
end;
---
180
ERROR 180-322: Statement is not valid or it is used out of proper order
Thank you for your help!
How about this instead: It will iterate 10 times, whatever you set amax too.
%let amax = 10;
%macro testme;
%do i = 1 %to &amax;
proc datasets lib=work kill memtype=data;
quit;
%end;
%mend testme;
%testme ;
:smileygrin:
The Do-End combination is part of a DATA step, you can't have PROC's within DATA steps. What SAS sees is the END; statement included in the PROC and it is not a valid statement for PROC DATASETS. That is the reason for the error message.
When I run your code, I also get the error message
ERROR 117-185: There was 1 unclosed DO block.
indicating that SAS did not see the END-statement in the DATA step.
However, the larger problem is that you are probably just getting into macro programming and want to actually execute the PROC 10 times. I would recommend that you read the chapter on macro language programming and go through the examples there before you launch out on your own.
Doc Muhlbaier
Duke
How about this instead: It will iterate 10 times, whatever you set amax too.
%let amax = 10;
%macro testme;
%do i = 1 %to &amax;
proc datasets lib=work kill memtype=data;
quit;
%end;
%mend testme;
%testme ;
:smileygrin:
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.