BookmarkSubscribeRSS Feed
MarkGIP
Calcite | Level 5

Hi everyone!

I'm quite new to SAS and I haven't worked with macros yet. Could you tell me if it's possible to loop an entire SAS program. With SAS program I mean different procedures such as DATA and IML. The program contains various random drawings and I would like to loop the program a certain number of times to get different results. The results for each run should be added to the previous results.

Since I'm using different procedures I was wondering if there might be a "simple" macro to do the loop. Or is it smarter to do individual loops for every procedure?

Thanks a million!!!

3 REPLIES 3
art297
Opal | Level 21

Depends!  Yes, you can wrap as many things as you would like to within one Macro.  It just can get complicated if you have to manage things like file names, variables, etc.  E.g.,

%macro doit;

   %do i=1 %to 1000000;

       proc whatever;

       run;

       proc whatever;

       run;

       etc.

   %end;

%mend doit;

%doit

data_null__
Jade | Level 19

You can loop an entire program but you may not want to.  You mention random drawings (samples) which suggests to me some sort of simulation.  I would suggest you look at SURVEYSELECT and BY group processing.  Tell us more about what you are actually trying to do.

You may find this paper useful http://analytics.ncsu.edu/sesug/2008/ST-143.pdf

Peter_C
Rhodochrosite | Level 12

%include is very handy when you have a few program's to run - or a program to run a few times

Chech the on line doc

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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