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 (June 2009, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 11 Jun 2009 02:32:20 -0700
Reply-To:     RolandRB <rolandberry@HOTMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         RolandRB <rolandberry@HOTMAIL.COM>
Organization: http://groups.google.com
Subject:      This macro problem has got me stumped
Comments: To: sas-l@uga.edu
Content-Type: text/plain; charset=ISO-8859-1

I have two macros as shown below.

%macro mvarlist(scopename,contents);

%local dsid rc name namenum value valuenum mvarlist contents2; %let mvarlist=;

%if not %length(&scopename) %then %let scopename=GLOBAL; %else %let scopename=%upcase(&scopename);

%if not %length(&contents) %then %let contents=any; %let contents2=%upcase(%substr(&contents,1,1)); %if not %index(ASE,&contents2) %then %do; %put ERROR: (mvarlist) Expected "any", "empty" or "set" but you supplied "&contents"; %goto error; %end;

%let dsid=%sysfunc(open(sashelp.vmacro(where= (scope="&scopename")),is)); %if &dsid EQ 0 %then %do; %put ERROR: (mvarlist) sashelp.vmacro not opened due to the following reason:; %put %sysfunc(sysmsg()); %goto error; %end; %else %do; %let namenum=%sysfunc(varnum(&dsid,name)); %let valuenum=%sysfunc(varnum(&dsid,value)); %end;

%readloop: %let rc=%sysfunc(fetch(&dsid)); %if &rc %then %goto endoff; %let name=%sysfunc(getvarc(&dsid,&namenum)); %let value=%sysfunc(getvarc(&dsid,&valuenum)); %if &contents2 EQ A %then %let mvarlist=&mvarlist &name; %else %if &contents2 EQ S %then %do; %if %length(&value) %then %let mvarlist=&mvarlist &name; %end; %else %if &contents2 EQ E %then %do; %if not %length(&value) %then %let mvarlist=&mvarlist &name; %end; %goto readloop;

%endoff: &mvarlist %let rc=%sysfunc(close(&dsid));

%goto skip; %error: %put ERROR: (mvarlist) Leaving mvarlist macro due to error(s) listed; %skip: %mend;

%macro mvarvalues(mvarlist,quotewithin);

%local i name;

%do i=1 %to %words(&mvarlist); %let name=%scan(&mvarlist,&i,%str( )); %put &name = %str(&quotewithin)%superq(&name)%str(&quotewithin); %end;

%mend;

But I run the following code and hit a problem as explained in the macro comment lines.

%macro dummy9(a=123,b=234,c=,d=); %*- the "put" below works fine... -; %put >>>>%mvarlist(dummy9,a)>>>>>>; %*- ....but the below line does not give me anything.... -; %mvarvalues(%mvarlist(dummy9,a),**); %*- ....but setting up a holding macro variables and using that does -; %let string=%mvarlist(dummy9,a); %mvarvalues(&string,--); %mend;

Can someone explain why I don't get anything in the combined from %mvarvalues(%mvarlist(dummy9,a),**);


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