An Idea Exchange for SAS software and services

by Born612
on ‎12-19-2012 12:01 PM

This is easily accomplished using &&ITEM&N. Looping 1 to &N will allow &&ITEM&N to be resolved for each iteration and incremented-value of &N. More complex values of &&ITEM&N can be macro-quoted, and then macro-unquoted during each of the loop's iterations.

by Regular Contributor
on ‎02-22-2013 03:50 PM

As Born612 commented, this is already possible.

Other possibilities are shown in Fehd and Carpenter's paper: List Processing Basics

by Contributor jaredp
on ‎04-09-2013 10:34 AM

"easily" accomplished? I would not consider &&ITEM&N "easy".  The current methods to loop over non numeric values leaves much to be desired.

Most other mature programming languages can easily loop over a list of non numeric values.  The lack of built-in features like this that make people view SAS as archaic and dismiss SAS as a solution.  It only serves to steepen the learning curve.

Being "possible" does not mean it is proper coding. What you want is minimal and easy to read code.

by PROC Star
on ‎04-12-2013 08:43 AM

I am with Jared on this one. Look at the richness of say the php functions for manipulation data vs sas. And contrarily to sas, php's main purpose is not even to manipulate data.

As for being seen as archaic, sas' weakest point is not the lack of built-in features, it is its developement environment. Or rather lack thereof.

by Contributor jaredp
on ‎04-12-2013 11:31 AM

I hadn't even thought about that last point you made, but you are right.  Many other languages have very feature-rich IDE's.  It took SAS how long to even get code completion in EG?   I like the improvements so far, but there is still much catch-up.

by PROC Star
on ‎04-12-2013 05:37 PM

And EG was never made for developers. It has a few extra features compared to the DMS, but it also lacks many of the DMS' already limited features, and is nothing like an IDE.

by Valued Guide
on ‎05-03-2013 03:20 AM

rather than the macro below, I would prefer the proposed enhancenent to the macro language,


would the following qualify as "easily"?

%mLoopsX( execut= nameYourMacroProcess

         , with= your list o f values )

There is a paper on this list processing macro to be found at


by Occasional Contributor Aad
on ‎05-17-2013 08:26 AM


How smart your solution may look and how brilliant the codfing under the hood may be, it requires a separate macro to contain the code, can be prone to inadvertent Global/Local conflicts, and does not - in contrast with many other Macro Language statements, conform to the like-named Data Step and SCL statements.

What I mean: "DO" in Data Step and SCL delivers the same functionality like many other 3GLs deliver through their "DO" statements.

The SAS Macro Language also contains a like functionality. However, if you want to use just one of the 4 possible "DO" clauses, you have to rely on a completely different approach.

Programming gets even less transparent to obtain the following Data Step "DO" constructs:

Example 1: multiple series

DO i = '00:00't to '00:04't by '00:01't

     , '00:05't to '00:25't by '00:05't

     , '00:30't to '1:30't by '00:15't

     , '02:00't to '24:00't by '01:00't;

Example 2: multiple constructs

DO i = 1 to 10

     , 25

     , 50 to 500 by 50

     , 750, 100;

Hope this explains how powerful "DO" is when compared to a combination of "%DO" and "%MloopsX" calls.

by Valued Guide
on ‎05-17-2013 05:34 PM


thank you for providing examples.

I'm aware of the how iterative DO processing differs in data steps and the base SAS macro language environment.

Are these examples that you anticipate the "idea" would support?


by Occasional Contributor Aad
on ‎05-18-2013 12:36 PM


Now that I re-read my post, I realize that my "idea" is different from, and stretches even further than what is proposed in the Ballot Item.

The basic idea behind the plain Ballot Item is the following construct:

%Do String = January, April, June, December;





In this construct (which again corresponds to one of the Data Step / SCL Do statements), the macro variable named &String will at first contain the text string January, in the second pass the string April, and so on.

But if you develop in a way that each comma-separated item may be either a number, a character string or a %TO-%BY loop definition, the syntax would evoluate towards the like-named Data Step and SCL statement.

Brgds., Aad

Idea Statuses
Top Liked Authors