LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (March 2009, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sun, 22 Mar 2009 17:06:28 -0400
Reply-To:     Ian Whitlock <iw1sas@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Ian Whitlock <iw1sas@GMAIL.COM>
Subject:      Re: Do Loop: Insert Macro Value row by row
Comments: cc: OR Stats <stats112@gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Summary: Efficiency issues #iw-value=1

OR Stats,

You might shorten by combining steps 2 and 3.

*append the results; data final; set final temp (in=temp) ; if temp then do ; m1=&macrovar1; m2=&macrovar2; end ; run;

If STUFF does not vary in the loop then it is hard to see how the PROC SUMMARY produces different results. If the summary step is not adequately shown it may be possible to use a BY statement and simplify the code and make it much more efficient.

You write, "Any comments on which types of steps run faster in SAS would be good discussions too."

In general procedures will execute faster than corresponding well constructed DATA steps. A well constructed DATA step will execute faster than a poorly constructed one. In general the fewer steps the better since it usually means fewer data passes. If you want more than perhaps it is best discussed in a particular context.

For example, if FINAL is big enough to be significant then

*add in macro variables; data temp; set temp; m1=&macrovar1; m2=&macrovar2; run;

*append the results; proc append base=final data=temp; run;

If FINAL is small enough then the first suggestion may be more appropriate.

In general, writing for maintenance is more important than speed unless the time is annoyingly large and done often enough.

In general, the design of data storage may be the greatest influence on the amount of time spent writing and running programs.

Ian Whitlock ===============

Date: Sun, 22 Mar 2009 07:26:50 -0500 From: OR Stats <stats112@GMAIL.COM> Subject: Re: Do Loop: Insert Macro Value row by row Comments: To: Andy Bowden <andybowden@gmail.com>

Thanks all for your reply. I ended up using the following in case it may be faster(?):

%do i = 1 to 10;

*create summary info; proc summary data = stuff; output out=temp; run;

*add in macro variables; %let macrovar1=...; %let macrovar2=...;

*Merge summary and macro info; data temp; set temp; m1=&macrovar1; m2=&macrovar2; run;

*append the results; data final; set final temp; run;

%end;

Any comments on which types of steps run faster in SAS would be good discussions too. Cheers

<snip>


Back to: Top of message | Previous page | Main SAS-L page