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 2008, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 15 May 2008 12:09:01 -0700
Reply-To:     karma <dorjetarap@GOOGLEMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         karma <dorjetarap@GOOGLEMAIL.COM>
Organization: http://groups.google.com
Subject:      Re: %str question?
Comments: To: sas-l@uga.edu
Content-Type: text/plain; charset=ISO-8859-1

On May 15, 5:54 pm, tonyliang20...@GMAIL.COM (Amy Sun) wrote: > Thank you for the suggestions, and if I want a macro taking the macro > variable as parameter, then how to revise the following code. > > %macro batchcodeA (param); > %do i = 1 %to &nvisit; > %let vis_a = %scan(&vValList, &i, %str( ) ); > %do j = 1 %to &nvisit; > %let vis_b = %scan(&vValList, &j, %str( ) ); > &param > %end; > %end; > %mend; > > %batchcodeA(%nrstr(STD_&vis_a.&vis_b)) > > Thank you for your help. > > Best regards, > Amy > > On 5/15/08, karma <dorjeta...@googlemail.com> wrote: > > > > > Hi Amy, > > > If you are trying to generate a string of variable names using your > > batchcode macro, try this: > > > %macro batchcode; > > %let nvisit=4; /*Remove this line*/ > > %let vVallist=this is a test; /*Remove this line*/ > > %let visx=STD_; > > %do i = 1 %to &nvisit; > > %let vis_a = %scan(&vValList, &i, %str( ) ); > > %do j = 1 %to &nvisit; > > %let vis_b = %scan(&vValList, &j, %str( ) ); > > %let visx=&visx.&vis_a.&vis_b ; > > %end; > > %end; > > &visx; > > %mend batchcode; > > > %let y=%batchcode; > > %put &y; > > > STD_thisthisthisisthisathistestisthisisisisaistestathisaisaaatesttestthistestistestatesttest > > > The code you have given will create a string with all combinations of > > each substring in vis_a with vis_b. This does seem a bit strange. What > > is it you want to use this for? HTH > > > On May 15, 3:57 pm, tonyliang20...@GMAIL.COM (Amy Sun) wrote: > > > Hi, All; > > > > I have the following code, and want to refer the macro &batchcode, in > > some > > > other place, > > > > %let batchcode = %nrstr( > > > %do i = 1 %to &nvisit; > > > %let vis_a = %scan(&vValList, &i, %str( ) ); > > > %do j = 1 %to &nvisit; > > > %let vis_b = %scan(&vValList, &j, %str( ) ); > > > STD_&vis_a.&vis_b > > > %end; > > > %end; > > > ); > > > > e.g. in some procedure, > > > > proc summary data = datacov mean; > > > class trt; > > > var &batchcode; > > > output out = stat_cov > > > mean = &bathcode N = ....; > > > run; > > > > there are some error message in the log, then how can I corrrectly define > > > the macro &batchcode. > > > > Thank you in advance for your suggestions. > > > > Best regards, > > > Amy

Is this what you are looking for?? If you can let us know what it is you are trying to do, I'm sure the board can suggest a better way to handle this.

%macro batchcode(param); %let nvisit=4; /*Remove this line*/ %let vVallist=this is a test; /*Remove this line*/ %let visx=; %do i = 1 %to &nvisit; %let vis_a = %scan(&vValList, &i, %str( ) ); %do j = 1 %to &nvisit; %let vis_b = %scan(&vValList, &j, %str( ) ); %let visx=&visx.&param ; %end; %end; &visx; %mend batchcode;

%let temp=%nrbquote(STD_&vis_a.&vis_b);

%let y=%batchcode(&temp); %put &y;


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