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:
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.
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.