- proc sort data=test;
- by dm;
- run;
- data test1 ;
- set test;
- by dm;
- if first.dm then num+1;
- run;
- proc sql noprint;
- select max(num) into:num from test1;
- quit;
- %macro exportfile(ds,n);
- %do i=1 %to &n;
- data tmp&i (drop=num);
- set &ds;
- where num=&i;
- run;
- proc sql noprint;
- select distinct(dm) into :filename from tmp&i;
- quit;
- %put &filename;
- proc export data=tmp&i dbms=dlm replace outfile="d:tmp&filename..txt";
- run;
- %end;
- %mend exportfile;
- %exportfile(test1,&num);