## Non continous do loop

Solved
Super Contributor
Posts: 713

# Non continous do loop

I want to skip iteration 19.

The following doesnt seem to work.

%macro zz;

data sasdata.som_all;

set %do i = 10 %to 18, 20 %to 23;
sasdata.som&i.
%end;;
run;
%mend  zz;
%zz;

Accepted Solutions
Solution
‎09-11-2013 03:57 PM
Occasional Contributor
Posts: 16

## Re: Non continous do loop

%macro zz;

data sasdata.som_all;

set %do i = 10 %to 23;

%IF &i NE 19 %Then sasdata.som&i.;
%end;;
run;
%mend  zz;

All Replies
Solution
‎09-11-2013 03:57 PM
Occasional Contributor
Posts: 16

## Re: Non continous do loop

%macro zz;

data sasdata.som_all;

set %do i = 10 %to 23;

%IF &i NE 19 %Then sasdata.som&i.;
%end;;
run;
%mend  zz;

Valued Guide
Posts: 2,191

## Re: Non continous do loop

have a look at http://communities.sas.com/ideas/1084 a ballot item which seems most relevant to your question. See the comment on 18-May-2013.

Posts: 3,852

## Re: Non continous do loop

Of course this is the same as program but I bit more general "to me".  For lists of data set you don't even need the macro you could write set som10-som18 some20-some24;  And as mentioned there is the effort to get the syntax of the more robust DO applied to the %DO.  I think we've been waiting on that since 1982.

data som10 som12 som14;
x=1;

run;
%macro zz;

%local i skip;
%let skip = 13,11;
data som_all;
set

%do i = 10 %to 14;

%if %sysfunc(whichn(&i,&skip)) %then %goto continue;
som&i.
%
continue: %end;
;
run;

%mend  zz;
options mprint=1;
%
zz;

Valued Guide
Posts: 2,191

## Re: Non continous do loop

```
we've been waiting on that since 1982.

```

we have enough in the macro language
"gild the lily" comes to mind (a half-remembered version of Shakespeare :)
🔒 This topic is solved and locked.