From: H S on
Hi suppose I have a bunch of libraries called CARSALE CARBRAND
CARWEIGHT
In each library there is a file called COUNT
How do I run a loop so that I can run proc means on each one of the
libraries

imaginary code:
array list(3) list1 list2 list3 ('carsale','carbrand','carweight');
for i 1 to dim(list);
do;
proc means data=list(i).count; /*In reality I want proc means
data=carsale.count data=carbrand.count data=carweight.count */
end;

Thank you.
From: billyk43 on

Here's one possible way:

data _null_;
set sashelp.vlibnam;
if substr(libname,1,3)="car";
n+1;
call symput('lib'||left(n),libname);
call symput('libcnt',trim(left(n)));
run;

%macro do_means;

%do i=1 %to &libcnt;

proc means data=&&lib&i...count;
run;

%end;

%mend;

%do_means;


Hope that helps.


Disclaimer: This has not been tested....



On Mar 21, 6:04 pm, H S <jin...(a)gmail.com> wrote:
> Hi suppose I have a bunch of libraries called CARSALE CARBRAND
> CARWEIGHT
> In each library there is a file called COUNT
> How do I run a loop so that I can run proc means on each one of the
> libraries
>
> imaginary code:
> array list(3)  list1 list2 list3 ('carsale','carbrand','carweight');
>    for i 1 to dim(list);
>    do;
>    proc means data=list(i).count; /*In reality I want proc means
> data=carsale.count data=carbrand.count data=carweight.count */
>    end;
>
> Thank you.