Date: Tue, 13 Nov 2007 18:00:13 -0500
Reply-To: Chang Chung <chang_y_chung@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Chang Chung <chang_y_chung@HOTMAIL.COM>
Subject: Re: Is there a way to automate filename changes
Content-Type: text/plain; charset=ISO-8859-1
On Tue, 13 Nov 2007 15:58:00 -0600, Edgar Sanchez
<Suppression@MAIL.UTEXAS.EDU> wrote:
>Greetings,
>
>I am appealing to those more knowledgeable than I in SAS for some help. In my
>sas code i am doing a number of replications that call on 10 different
>datasets. for example I need to input
>
>%let respdat='D:\my docs\UT Documents\PhD & MA\PhD\Dissertation SAS
>Docs\CATs\Response files\gpc100_6.dat';
> /*path for examinees' responses(resp)*/
>
>And I need to output the results for that dataset to:
>
>%let dvfile='D:\my docs\UT Documents\PhD & MA\PhD\Dissertation SAS
>Docs\CATs\RWi1\9RWi1dv100_6.uni';
> /*output path for dep vars*/
>%let ncfile='D:\my docs\UT Documents\PhD & MA\PhD\Dissertation SAS
>Docs\CATs\RWi1\9RWi1dnc100_6.uni';
> /*output path for nonconvergent cases*/
>
>So you can see that I my input and output are marked as ��_6.*� right now I am
>manually changing these three lines for every replication. Ive done 70 of these
>conditions manually but I still have 210 to go. So my hope is that there is a
>way to automate this process. As I am good with basic sas code but not very
>complex code I have not found a way to do this (assuming it can be done). Any
>ideas on this would be greatly appreciated.
hi, Edgar,
wonderful job naming directories with embedded blanks and special
characters... very nice! :-)
solutions depends... creating the above three macro vars with minimal input
is easy, though. compile the macro iofiles and then call it using the
number. Once the macro is called, then the three macro variables are set. It
is kind of short-cut of search-and-replace you do. HTH.
cheers,
chang
%macro iofiles(num=);
%local sQ PhD Cats fn;
%global respdat dvfile ncfile;
%let sQ = %str(%');
%let PhD = D:\my docs\UT Documents\PhD %nrstr(&) MA\PhD\;
%let Cats = Dissertation SAS Docs\CATs\;
%let fn = Response files\gpc100_&num..dat;
%let respdat = %unquote(&sQ.&PhD.&Cats.&fn.&sQ.);
%let fn = RWi1\9RWi1dv100_&num..uni;
%let dvfile = %unquote(&sQ.&PhD.&Cats.&fn.&sQ.);
%let fn = RWi1\9RWi1dnc100_&num..uni;
%let ncfile = %unquote(&sQ.&PhD.&Cats.&fn.&sQ.);
%mend iofiles;
%iofiles(num=6)
/* now the three macro vars are set with number 6 */
%put respdat=&respdat.;
%put dvfile=&dvfile.;
%put ncfile=&ncfile.;
%iofiles(num=7)
/* now the three macro vars are set with number 7 */
%put respdat=&respdat.;
%put dvfile=&dvfile.;
%put ncfile=&ncfile.;