| Date: | Tue, 14 Feb 2006 13:24:22 -0500 |
| Reply-To: | Kevin Roland Viel <kviel@EMORY.EDU> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Kevin Roland Viel <kviel@EMORY.EDU> |
| Subject: | Re: macro resolution |
| In-Reply-To: | <200602141738.k1EGIZoK016525@mailgw.cc.uga.edu> |
| Content-Type: | TEXT/PLAIN; charset=X-UNKNOWN |
Denise,
Good to have you join us :) I am no authority, but Quentin is quiet
lately. I assume you have Ian's papers? Check the SESUG proceedings from
St. Pete's Beach, I think he contributed one then. I have interleaved
some remarks to get you started. I think you were looking in the right
direction.
On Tue, 14 Feb 2006, Denise Figliozzi wrote:
> I’m having a problem with my looping macro variable.
>
> Data _null_;
> Set datasource end=no_more;
> call symput('NAME'||left(_n_),FULL_NM);
>
> if no_more then call symput('offcnt',_n_);
> run;
This works, but there may be more elegance and functionality in:
proc sql noprint ;
select distinct trim( left( FULL_NM )) into : name1 - : name9999
from datasouce
;
quit ;
%let offcnt = &sqlobs. ;
>
> *** the value inside NAME looks like this : Figliozzi, Denise
>
> %macro ofcrloop;
> %local i;
> %do i=1 %to &offcnt.;
>
> %macro innerloop(rm);
> < looping through proc report, etc here >
>
> %mend innerloop;
> %innerloop(&&NAME&i.);
> %end;
> %mend ofcrloop;
> %ofcrloop;
Yikes! My personal preference would be to separate the macro definitions:
%macro innerloop ( rm ) ;
%mend innerloop ;
%macro ofcrloop ;
%mend ofcrloop ;
Also, be careful of using the semi-colon trailing a macro call:
%innerloop( &&NAME&i. );
^
> Problem: The macro &&NAME&i. will not resolve correctly because of the
> comma between first and last name. So, I can get around this by inserting
> quotation around the macrolike so: ‘&&NAMEi.’
>
> However, on my report, the output looks like this : ‘Figliozzi,
> Denise ‘
The use of the LEFT() and TRIM() functions above will take care of the
trailing spaces. COMPBL() may even be useful. I would have thought think
that %NRBQUOTE would have worked.
Exactly how are you using &&NAME&i.?
> I have fooled around with quoting functions such as %superq, %nrbquote, %
> quote to no avail. Can anyone guide me to the function I need that will
> preserve the value with the comma separated name but allow me to pass it
> through the macro?
>
> Thanks for your help.
>
> Denise Figliozzi
>
> SAS Programmer
>
> SunTrust Banks, Inc.
> Mail Code GA-ATL-0674
> 303 Peachtree Center Ave., Suite 300
> Atlanta, GA 30303
> voice: 404.230.5547
> fax : 404.658.4083
> ST NET 340-5547
>
> Seeing beyond money (sm)
Good luck,
Kevin
Kevin Viel
Department of Epidemiology
Rollins School of Public Health
Emory University
Atlanta, GA 30322
|