From: arun on
Hi all,

The situation is like

I have about 6 datasets and i need to combine them into one so I have
used the set statement as

data one;
set
%do i = &m %to &n
sum_&i
%end;
;
run;

i am parametrizing to get the first in some cases or 4 - 6 in some
cases but if i need to combine only 1 and 4 and assuming there are no
dataset for sum_2 and sum_3 as if i specify 1-4 I will be getting
error. So Can anyone please help me how can i come over this
limitation where i should be able to parametrize such as
1-6
1-3
4-6
1 and 4
in the same do loop.

Please help
From: Ya on
On Jun 16, 11:45 am, arun <aruku...(a)gmail.com> wrote:
> Hi all,
>
> The situation is like
>
> I have about 6 datasets and i need to combine them into one  so I have
> used the set statement as
>
> data one;
> set
> %do i = &m %to &n
> sum_&i
> %end;
> ;
> run;
>
> i am parametrizing to get the first in some cases or 4 - 6 in some
> cases but if i need to combine only 1 and 4 and assuming there are no
> dataset for sum_2 and sum_3 as if i specify 1-4 I will be getting
> error. So Can anyone please help me how can i come over this
> limitation where i should be able to parametrize such as
> 1-6
> 1-3
> 4-6
> 1 and 4
> in the same do loop.
>
> Please help

How about something like this:

1 %macro dc(ds=);
2 %let ds1=sum%sysfunc(tranwrd(&ds,|,sum));
3 %put &ds1;
4 %mend dc;
5
6 %dc(ds=1 |2 |3 |4)
sum1 sum2 sum3 sum4
7 %dc(ds=1 |4)
sum1 sum4
8 %dc(ds=4 |5 |6)
sum4 sum5 sum6

The parameter is a list of dataset number separated by a space and '|'

HTH

Ya