3

I'm currently working on an important project where we use logistic regression to predict events.

The thing is, I need to generate 2 distinct sample of 1500 peoples then process a logistic regression. This whole process should be looped 50 times minimum. Do you know a way to loop it 50 times?

I tried with a macro:

%macro repeat
    %do i = 1 %to 50;
      [...]
      output;
      end;
    run;
%mend;
%repeat(50);

But it won't work. Do you have any idea?

  • Please provide a [minimal, verifiable and complete example](https://www.stackoverflow.com/help/mcve) of the code that causes the problem, and include the corresponding log output. – user667489 Apr 11 '18 at 12:39
  • In your sample code the `%do` has no matching `%end`, which should trigger an obvious error message when attempting to compile the macro, but without seeing a more complete code example it isn't possible to say whether this is the only problem. – user667489 Apr 11 '18 at 12:41
  • http://www2.sas.com/proceedings/forum2007/183-2007.pdf – Reeza Apr 11 '18 at 21:00
  • 1
    The SAS way, would be to generate all samples at once, 2*1500*50 = 150,000 which is small still. SAS can easily handle that with BY group processing which avoids macros entirely. The paper above details how that can be accomplished. – Reeza Apr 11 '18 at 21:01
  • Thanks Reeza, I didn't think about this way of solving the problem. But it seems to be a more effective way for random sampling as I'm selectioning an observation only once, it avoid getting copies of the same observation as if I randomly sampled 50 times. – Clément Hurel Apr 12 '18 at 09:11

1 Answers1

1

To solve the problem, I had to trick the editor into thinking it have reached the end of the whole macro. Juste insert the code below under %macro :

%local DUMMY;
%let DUMMY = %nrstr(%mend);

If you're seeking for repetition of SURVEYSELECT then just add REPS=n

You can check full answer here: Why does my code inside my macro is not taken into account?