-1

Say I have this code:

data Work.dataset;
do i = 3 to 7;
    %let mname = text;
    %let mname = &mname.i;
end;
run;

I want the i in %let mname = &mname.i; to refer to i = 3 to 7 and not to the letter i. How can I make this happen?

The real question I am trying to get at is found here: Loop over strings and read in files and save and I am trying to figure out a way to do this. This question was trying to tackle a part of that larger question.

Community
  • 1
  • 1
bill999
  • 2,147
  • 8
  • 51
  • 103

1 Answers1

0

You can't use %let in data steps, use call symput.

This works better. I hope it's what you wanted.

data Work.dataset;

    do i = 3 to 7;
        mname1 = 'text';
        mname2 = mname1||put(i,1.);
        call symput('mname3',mname2);
        put mname2;
        output;
    end;
run;

%put mname3=&mname3;
stallingOne
  • 3,633
  • 3
  • 41
  • 63