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 (May 1997, 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 May 1997 14:38: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: Macro Question
Comments:   cc: RSTEVENS@BCBSCT.COM, bernard@pollux.BITNET

Hi,

I presumed that the last macro call "%print1" was misspelled and was "%report1". Since you evaluate the value of your macro variables "printx,sip,sip_lbl" in the data step you can't call "proc report" while looping in the data step... SAS assume that it must do the data step first and lastly does the proc report. This explain why you have only one report ...

Now, how do you execute a macro while looping in a data step ??? Answer: use call execute; first to assign the value to your macro variables; and then to call the macro. example:

>>> data _null_; >>> set rptcntrl end=last; >>> call execute('%let prindx='||prin_dx||';'); >>> call execute('%let sip='||sip_ind||';'); >>> call execute('%let sip_lbl='||put(sip_ind,$sip.)||';'); >>> call execute('%report1;run;'); >>>run; >>>

NB: The macro variables printdx, sip and sip_lbl could have been passed as macro parameters...

Regards,

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 Thu May 29 13:11 EDT 1997 >>>Date: Thu, 29 May 1997 13:03:10 -0400 >>>From: RICHARD STEVENS <RSTEVENS@BCBSCT.COM> >>>Subject: Macro Question >>>To: Multiple recipients of list SAS-L <SAS-L@UGA.CC.UGA.EDU> >>> >>>Hi all, >>>I am trying to run a macro that prints a report. I want to execute the >>>macro from a data step where I set macro variables to be used in Proc >>>Report. The following code runs, but the report only creates a report for >>>the last record in the input data; >>> >>>What am I doing wrong. Any help will be appreaciated. TIA. >>> >>>Richard >>> >>>Sample Code: >>> >>>%macro report1; >>>** Create a report **; >>>proc report data=mdstat2.icd01 headline headskip split='~'; >>> column corp_ent pat_lst pat_1st >>> grp_no mbrshp_n pat_rel_ pat_sx_c pat_bth >>> offvst offvstpd >>> hspip hspippd hspop hspoppd lab_amt; >>> where prin_dx="&prindx" and sip_ind="&sip"; >>> define corp_ent /group width=10 'Entity'; >>> << more code >> >>> break after corp_ent / ol ul skip summarize; >>> rbreak after / dol dul skip summarize; >>> title2 'Hospital and Med/Surg '; >>> title3 "Incurred - &incrmmyr., Paid - &pdmmyr."; >>> title4 "&prindx -- &sip_lbl"; >>> run; >>> %mend report1; >>> >>> proc sql; >>> create table rptcntrl as >>> select distinct prin_dx ,sip_ind >>> from mdstat2.icd01 >>> ; >>> >>> data _null_; >>> set rptcntrl end=last; >>> call symput('prindx',prin_dx); >>> call symput('sip',sip_ind); >>> call symput('sip_lbl',(put(sip_ind,$sip.))); >>> %print1 >>>run; >>>


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