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 (August 2008, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Sun, 10 Aug 2008 10:01:03 +1000
Reply-To:   Scott Bass <sas_l_739.at.yahoo.dot.com.dot.au@PESTO.CC.UGA.EDU>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Scott Bass <sas_l_739.at.yahoo.dot.com.dot.au@PESTO.CC.UGA.EDU>
Subject:   Re: Global macro var stops working
Comments:   To: sas-l@uga.edu

"RolandRB" <rolandberry@hotmail.com> wrote in message news:1fa244ce-f5c6-4f39-9fa9-55a0b2864bac@j22g2000hsf.googlegroups.com... On Aug 9, 4:04 am, earlin...@GMAIL.COM (Chris Sanders) wrote: > Hi, y'all, > > This is one of those "it worked until now with no changes" things. > Something -must- have changed but two hours of trying hasn't turned up > anything. > > The macro var in this isn't taking - it's coming out blank, but I swear it > worked before. Only even then I couldn't figure out how it was getting a > value into sqlfile. > > %global sqlfile; > %macro backemup; > %let dsid=%sysfunc(open(tablesnow,is)); > %syscall set(dsid); > %let nomore = %sysfunc(attrn(&dsid,NOBS)); > %do i = 1 %to &nomore; > %let rc=%sysfunc(fetchobs(&dsid,&i)); > proc sql; > create table datalib2.&sqlfile > as > select * from datalib1.&sqlfile; > %end; > %let dsid=%sysfunc(close(&dsid)); > %mend backemup; > > Any help that lets me get on with my Friday night would be greatly > appreciated! > > Chris

> sqlfile might have been set somewhere else before it was declared as > global.

I suspect sqlfile is meant to be set by the %syscall set(dsid) statement. I bet tablesnow contains the variable "sqlfile".

Chris, it's important to know when NOT to use macro as it is when TO use macro. In this case, you're WAY overusing macro, and this would perform badly.

It looks like you're doing a backup of a library using a list of datasets defined in tablesnow.

Try this instead:

proc sql noprint; select sqlfile into :list separated by " " from tablesnow; quit;

proc copy in=datalib1 out=datalib2; select &list; run;

HTH, Scott


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