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

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;

1 ACCEPTED SOLUTION

Accepted Solutions
Jakkas
Calcite | Level 5

How about

%macro zz;

     data sasdata.som_all;

      set %do i = 10 %to 23;

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

View solution in original post

4 REPLIES 4
Jakkas
Calcite | Level 5

How about

%macro zz;

     data sasdata.som_all;

      set %do i = 10 %to 23;

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

Peter_C
Rhodochrosite | Level 12

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.

data_null__
Jade | Level 19

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;

Peter_C
Rhodochrosite | Level 12

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

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1063 views
  • 0 likes
  • 4 in conversation