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 1997, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 23 Jul 1997 10:28:11 +0500
Reply-To:     Bernard Tremblay <bernard@CAPITALE.QC.CA>
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         Bernard Tremblay <bernard@CAPITALE.QC.CA>
Subject:      Re: creating files using macro
Comments: To: mcadavillo@HEALTHFIRST.ORG
Comments: cc: miqy@concentric.net, bernard@pollux.BITNET

Hi,

You should use proc freq and output the different values of fn into a SAS file, then call execute your macro. But add the value of fn as a parameter to your macro. In the macro you will do the file allocation. Example:

proc freq data=inuse; table fn/out=f1 ; run; data _null_; set f1; call execute('%gom('||fn||');'); run;

Beforehand, you should modify the macro to begin with:

%macro gom(fname); filename out1 "r:\mike\sasout\newmas\&fname"; ... the rest of the macro stays the same... %mend;

I hope this helps,

Bernard Tremblay \\\|/// \\ - - // ( @ @ ) +------oOOo-(_)-oOOo----------+---------------------------------+ | Bernard Tremblay | | | La Capitale | Tel: (418) 646-2401 | | | Fax: (418) 646-5960 | | | Int: bernard@capitale.qc.ca | +-----------------------------+---------------------------------+ | Imaginasys enr | Res: (418) 878-4447 | | | Int: bertrem@quebectel.com | +---------------Oooo----------+---------------------------------+ oooO ( ) ( ) ) / \ ( (_/ \_) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >>>From owner-sas-l@UGA.CC.UGA.EDU Wed Jul 23 10:04 EDT 1997 >>>Date: Wed, 23 Jul 1997 10:02:50 -0400 >>>From: "Cadavillo, Michael" <mcadavillo@HEALTHFIRST.ORG> >>>Subject: creating files using macro >>>To: SAS-L@UGA.CC.UGA.EDU >>> >>> Hi! I wrote up a macro to create multiple files - total of 180 files. >>> I copied part of the program in the bottom of my mail. It works >>> perfectly but it has a weakness I would like to get around with that >>> maybe other SAS users can help. >>> Here are the weaknesses I identified. fn is a variable in the data >>> set inuse. fn is how I limit the observations that would be written >>> to files. There is a total of 180 unique fn in the data set inuse. >>> The name of the file I am creating would have the value of the fn >>> variable. In order for my program to work I have to do the following: >>> 1. Identify all the unique fn and then define a macro variable. >>> 2. In my filename statement I would have to also define the name of >>> the file. >>> If I have to run the same program, I would have to keep on defining >>> the fn first before I can run this. I would like to run this program >>> without having to define all the fns first. Also to limit and create >>> a file for each value of the fn. Please help. Thank you. >>> >>> >>> >>> >>> %macro gom; >>> >>> data exp; set inuse; >>> where fn = &fname; >>> data _null_; set exp; >>> file out1; >>> put '"'newacct +(-1) '","'&fname +(-1) ' To post from old MAS90",'amt; >>> >>> %mend gom; >>> >>> %let fname = '1APR0138'; filename out1 >>> 'r:\mike\sasout\newmas\1APR0138.txt'; %gom >>> %let fname = '1APR0139'; filename out1 >>> 'r:\mike\sasout\newmas\1APR0139.txt'; %gom >>> %let fname = '1APR0141'; filename out1 >>> 'r:\mike\sasout\newmas\1APR0141.txt'; %gom >>> %let fname = '1APR0144'; filename out1 >>> 'r:\mike\sasout\newmas\1APR0144.txt'; %gom >>> %let fname = '1APR0147'; filename out1 >>> 'r:\mike\sasout\newmas\1APR0147.txt'; %gom >>> %let fname = '1APR0148'; filename out1 >>> 'r:\mike\sasout\newmas\1APR0148.txt'; %gom >>> %let fname = '1APR0149'; filename out1 >>> 'r:\mike\sasout\newmas\1APR0149.txt'; %gom >>> %let fname = '1APR0150'; filename out1 >>> 'r:\mike\sasout\newmas\1APR0150.txt'; %gom >>> >>> >>> Please respond at mcadavillo@healthfirst.org and >>> miqy@concentric.net >>> >>> Michael Cadavillo >>>


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