BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
hdg
Obsidian | Level 7 hdg
Obsidian | Level 7

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!

1 ACCEPTED SOLUTION

Accepted Solutions
bwasicak
Calcite | Level 5

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:

View solution in original post

2 REPLIES 2
Doc_Duke
Rhodochrosite | Level 12

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

bwasicak
Calcite | Level 5

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:

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!

What is Bayesian Analysis?

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.

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
  • 1171 views
  • 3 likes
  • 3 in conversation