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-2024.png

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.

 

Register now!

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.

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
  • 4 replies
  • 898 views
  • 0 likes
  • 4 in conversation