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 (March 2004, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 29 Mar 2004 18:19:11 +0000
Reply-To:     iw1junk@COMCAST.NET
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Ian Whitlock <iw1junk@COMCAST.NET>
Subject:      Re: macro for monthly pull from base file
Comments: To: LDM2004 <losdiablosmarch2004@YAHOO.COM>

Question:

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> how do i make the set statement at the end of my program to reference the file names in a macro instead of referencing the actual name?

option obs=max; %macro pull (n, date); data hmo&n&date(keep=member_no prpr_id grgr_id); set hmo.members; datevar=input(put(ym_to,8.),yymmdd10.); mo=month(datevar); yr=year(datevar); if mo=&n and yr=&date; run ;

%mend pull;

%pull(1,2001); %pull(2,2001); %pull(3,2001);

*Put files together into one large base file; data all; set hmo12001 hmo22001 hmo32001; run; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

From the code I would skip the question and simplify.

/* test data */ data hmo_members ; do member_no = 1 to 5 ; ym_to = put ( mdy ( member_no , 1 , 2001 ) , yymmdd10. ) ; output ; end ; run ;

%macro pull_all (start=jan2001, end=mar2001); data all(keep=member_no ym_to); set hmo_members; datevar=input(put(ym_to,$10.),yymmdd10.); if "1&start"d <= datevar <= "1&end"d ; run ; %mend pull_all ;

%pull_all ( )

One advantage of this approach is that you can cross year boundaries easily.

Ian_Whitlock@comcast.net


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