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 (February 2001, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sun, 4 Feb 2001 19:50:22 -0600
Reply-To:     Jonathan_Goldberg@MASTERCARD.COM
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Jonathan Goldberg <Jonathan_Goldberg@MASTERCARD.COM>
Subject:      What do I unquote?
Content-type: text/plain; charset=us-ascii

I'm writing some code to help me manage GDGs. The platform is V8 running under Solaris 5.6 As one step, I wish to count the number of back generations of selected GDGs under the assumption that I know what library they're in. The information needs to be passed into macro variables. I wrote this macro:

%macro GetNofGens; %local GDataset i; %let i = 1; %let GDataset = %scan(&GDGS, &i); %do %while (&GDataset ^=); %unquote((&GDataset select put(count(*), 1.) into :&GDataset.count from dictionary.tables where memname contains '#' and upcase(memname) contains upcase(%str(%')&GDataset%str(%')) ) ; %let i = %eval(&i + 1); %let GDataset = %scan(&GDGS, &i); %end; %mend GetNofGens;

The variable GDGS will be set to the list of GDGs in which I am interested. This is intended to be part of a proc sql invocation, and to read from dictionary.tables the information I need.

When I first ran this, the generated code looked correct but failed. This is usually diagnostic of quoting/tokenization problems. I tried %unquote in various places; finally, as above, I unquoted the entire generated text. The run-time result is:

290 proc sql; 291 %GetNofGens MPRINT(GETNOFGENS): select put(count(*), 1.) into :oldclusterscount from dictionary.tables where memname contains '#' and upcase(memname) contains upcase('oldclusters') ; MPRINT(GETNOFGENS): select put(count(*), 1.) into :basedatacount from dictionary.tables where memname contains '#' and upcase(memname) contains upcase('basedata') ; MPRINT(GETNOFGENS): select put(count(*), 1.) into :statusLcount from dictionary.tables where memname contains '#' and upcase(memname) contains upcase('statusL') ; MPRINT(GETNOFGENS): select put(count(*), 1.) into :accountscount from dictionary.tables where memname contains '#' and upcase(memname) contains upcase('accounts') ; MPRINT(GETNOFGENS): select put(count(*), 1.) into :deptsprtcount from dictionary.tables where memname contains '#' and upcase(memname) contains upcase('deptsprt') ; 292 ; 293 quit;

This code runs, and counts the data sets correctly. However, the macro variables are *not* set:

WARNING: Apparent symbolic reference OLDCLUSTERSCOUNT not resolved. 294 295 %put oldclusterscount is &oldclusterscount; oldclusterscount is &oldclusterscount

I can kludge are my most pressing requirements by hard-coding; if I don't use the macro everything works. I can see other ways to approach the problem.

My questions to you, oh sages of SAS-L, are: what is wrong with *this* approach; and, how can it be fixed?

Jonathan


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