Prev: Data step Do loop to change the value of Macro Variable
Next: How to get the last non-missing variable value
From: Tom Abernathy on 21 Feb 2010 10:00 I think you are asking if you could just iterate ovar a list of dataset names? Similar to what you can with DATA step DO loop like this: do name = 'p_one','p_two','p_three' ; ... end; I do not know of a way to do that with macro logic, but you could use a delimited list of names in a macro variable instead; %let names=p_one p_two p_three; %do i=1 %to %sysfunc(countw(&names)); %let name=%scan(&names,&i); ... %end; On Feb 21, 1:07 am, kuh...(a)126.COM (Clark An) wrote: > %do q = 1 %to &n; > PROC FSEDIT DATA=dedata.p&&dsn&q mod > SCREEN=GLSCN.descn.p&&dsn&q...SCREEN; > RUN; > %end; > > Is it possible to just use do not %do in the sample code,but set macro > variable q value with the loop values? > > TIA
From: Joe Matise on 21 Feb 2010 12:12 You could rewrite that code with CALL EXECUTE in a datastep, which would make use of DO instead of %DO. But I don't know why you'd ask the question that way. If you have a particular reason for this and it isn't an exam question or something, feel free to write back to the list with a bit more detail so we can advise you better. Thanks, Joe On Sun, Feb 21, 2010 at 12:07 AM, Clark An <kuhasu(a)126.com> wrote: > %do q = 1 %to &n; > PROC FSEDIT DATA=dedata.p&&dsn&q mod > SCREEN=GLSCN.descn.p&&dsn&q...SCREEN; > RUN; > %end; > > Is it possible to just use do not %do in the sample code,but set macro > variable q value with the loop values? > > TIA >
From: xlr82sas on 21 Feb 2010 13:57 On Feb 21, 9:12 am, snoopy...(a)GMAIL.COM (Joe Matise) wrote: > You could rewrite that code with CALL EXECUTE in a datastep, which would > make use of DO instead of %DO. But I don't know why you'd ask the question > that way. If you have a particular reason for this and it isn't an exam > question or something, feel free to write back to the list with a bit more > detail so we can advise you better. > > Thanks, > Joe > > On Sun, Feb 21, 2010 at 12:07 AM, Clark An <kuh...(a)126.com> wrote: > > %do q = 1 %to &n; > > PROC FSEDIT DATA=dedata.p&&dsn&q mod > > SCREEN=GLSCN.descn.p&&dsn&q...SCREEN; > > RUN; > > %end; > > > Is it possible to just use do not %do in the sample code,but set macro > > variable q value with the loop values? > > > TIA If your are using 9.2 I think you can accomplish this using FCMP and RUN_MACRO. I am on my mac right now and do not have access to SAS. data _null_; do q=1 to 10; call fse(q,'dsn'); end; stop; run;
From: Clark An on 22 Feb 2010 11:14 Thank you. I just wanna drop the %do but there's a problem when naming variables with macro variable; and for the example you have given,Am afraid there r to many names...
From: Clark An on 22 Feb 2010 11:16
Thank you. And how abt: do i=1 to 5; ..../*setting value of macro variable*/ x&i=&i; end; |