LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (December 2005, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 7 Dec 2005 14:50:04 -0500
Reply-To:   "Richard A. DeVenezia" <rdevenezia@WILDBLUE.NET>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Richard A. DeVenezia" <rdevenezia@WILDBLUE.NET>
Subject:   Re: Possible to run a SAS program within another SAS program?
Comments:   To: sas-l@uga.edu

oseithedude@gmail.com wrote: > Hello, I have 9 SAS programs, all within the same Windows folder that > I usually run at the same time - one right after the other. For > convenience, is it possible to write a simple SAS program that will > let me run all the programs at once or to have a program that will > allow me to pick and choose which SAS programs I want to run (e.g., > in the case I only want to run the first 3 and last program out of > the 9 SAS programs) and which order the programs are run in? I guess > what I'm really looking for is if there is a way to call another SAS > program using only a couple lines of code so that, if I choose not > run that program, I can just comment that code out or something like > that. Let me know if this is possible, thanks!!! > > Julie

This is an excellent scenario for a SAS/AF frame.

Supposing you don't have AF: The File/Open dialog has a Submit checkbox. When checked and you select _more than one_ file in the file dialog, each file will be submitted in sequence. The only caveat is that the order submitted is reverse of as show in the file dialog Filename field. E.g. "a.sas" "b.sas" "c.sas" will cause the submittal of C then B then A.

The same sort of issue occurs when multiple files are selected in straight up Windows Explorer (which the File.Open dialog utilizes). Basically, a Windows LIFO stack of file selections is causing the reversal.

An alternative would be to write a program that writes a program that contains only include statements based on a directory listing.

generate this code from input of filename listing PIPE "DIR /B *.sas" /** / %include "A.sas"; /**/ /** / %include "B.sas"; /**/ /** / %include "C.sas"; /**/

Note the space in the leading 'almost' comment block. Since there is a space, the comment extends to the trailing comment block which closes the leading 'almost'.

To run a select series of programs, simply remove the space from the leading almost comment block from which ever programs you want to run.

Run A and C. /**/ %include "A.sas"; /**/ /** / %include "B.sas"; /**/ /**/ %include "C.sas"; /**/

IIRC, this style of commenting, for easy on/off of code blocks, was made popular by Ron Fehd.

-- Richard A. DeVenezia http://www.devenezia.com/


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