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 (July 2004, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 29 Jul 2004 11:49:11 -0600
Reply-To:     Roberto Valdivia <valdivia@MONTANA.EDU>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Roberto Valdivia <valdivia@MONTANA.EDU>
Subject:      Re: Several datasets, one program
Comments: cc: Howard_Schreier@ita.doc.gov
In-Reply-To:  <s108fe29.049@hchb.ita.doc.gov>
Content-Type: text/plain; charset="us-ascii"

Hi again,

I am sorry to bother you with this problem. I am not sure how to set up a SAS macro to run with my program, so I thought I better send the structure of my program to see how can I adapt it to run with macros.

Thanks for your help.

Roberto.

/* The program starts by reading DBF files, some of them will be the same for all the runs, But there is one that will be different each time, also there is an output filename that Will be changing also in each run*/

FILENAME parm1 'c:\base\parm1.dbf'; * this is an input file that will be the same for all runs; FILENAME parm2 'c:\base\parm2.dbf'; * this is an input file that will be the same for all runs; FILENAME parm3 'c:\base\parm3.dbf'; * this is an input file that will be the same for all runs; FILENAME FIELD 'c:\files\data_A1.DBF';* THIS IS THE DATASET THAT WILL CHANGE: I HAVE DATA_A1.DBF, DATA_A2.DBF ,ETC, etc. FILENAME OUTDAT 'c:\results\RES_A1.dbf'; *THIS IS THE OUTPUT FILE WHERE THE RESULTS WILL BE SAVED, AND OF COURSE THE NAME WILL CHANGE ACCORDING TO THE INPUT DATASET USED.

PROC DBF DB4=PARM1 OUT=PARM1; PROC DBF DB4=PARM2 OUT=PARM2; PROC DBF DB4=PARM3 OUT=PARM3; PROC DBF DB4=field OUT=field0;

/* then the process starts by reading these files, estimating some means+others and then merging the data to start the analysis -this is all the process. In the process there is a parameter that I also would like to change its value, but this is probably much complicated, so don't worry about that*/

*the last line of the program is:

PROC DBF DATA=OUTDAT DB4=OUTDAT; RUN; *This line produces the final DBF file.

So, as I explained before I need to find a way so I can run the program once so it can read automatically the first input file, run the process and get the output file, start again with the next input file, run the process, create a second output file, and so on..

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Howard Schreier Sent: Wednesday, July 28, 2004 3:25 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Several datasets, one program

I would create one macro to run your program once, with the two parameters (dataset number and the other one) as arguments. Then have a second macro loop and invoke the first macro. Here's an example:

data demo1; retain v 1; run;

data demo2; retain v 2; run;

%macro program(dsnum=,dplaces=);

data out&DSNUM&DPLACES; set demo&DSNUM; format v 6.&DPLACES; run;

%mend program;

%macro loop(times=);

%do i = 1 %to &TIMES; %program(dsnum=&I, dplaces=1) %program(dsnum=&I, dplaces=3) %end;

%mend loop;

%loop(times=2)

On Wed, 28 Jul 2004 12:18:47 -0600, Roberto Valdivia <valdivia@MONTANA.EDU> wrote:

>Dear All, > >Maybe somebody has an idea on how to make this problem easier: > >I have a SAS program that uses 1 dataset (A.dbf) as input and I get one >dataset as output (Z.dbf). >I have 28 datasets "A" (a1..A28), which means that I have to run the program >28 times, >But there is more: I also have to change a value in one parameter in >the SAS >program, >which means that I actually have to run the program 56 times and get >the final databases (ZA1_1, ZA1_2, ZA2_1, ZA2_2,...ZA28_1, ZA28_2). > >Is there any way (macro, program, etc?) that I can use so I can run a single >program >And it automatically changes/updates : a. The input database name b. >the Output database name and c. the parameter value inside the program

>(The first two are the key, if >the parameter >value cannot be changed but the input and output database names can, >then I still will save a lot of time, I just will have to run again the >program with the other parameter's value) > >I don't know how complicated or easy this is, but any help will be welcome!. > >Thanks, > >Roberto


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