BookmarkSubscribeRSS Feed
sasuser123123
Quartz | Level 8

Hi .

I have a library  'mine' in  that  6 datasets are there data1-data6..So I need to export only 3 datasets to excel along with the contents dataset for those three also. How to do export using proc export.is there any options or statements to give selected datasets in proc export.

 

2 REPLIES 2
Shmuel
Garnet | Level 18

proc export deals with one datset at a time.

If you want to reduce programming create a macro program and supply the dataset names as argument:

%macro xprt(dsnames);
    %let n = %sysfunc(countw(&dsnames));
    %do i=1 %to &n;
           %let dsn = %scan(&dsnames,&i);
            proc export data=&dsn ... ;
                  .... other options ...
            run;
     %end;
%mend xprt;
%xprt(data1 data3 data4 ...);

You can define, similarly, a list of excell filenames or use a fix prefix with appropriate suffix like  XLDATA&i     

 

andreas_lds
Jade | Level 19

@sasuser123123 wrote:

Hi .

I have a library  'mine' in  that  6 datasets are there data1-data6..So I need to export only 3 datasets to excel along with the contents dataset for those three also. How to do export using proc export.is there any options or statements to give selected datasets in proc export.

 


  • proc export can only process one dataset with each call
  • using the same filename will overwrite the file
  • please explain what you mean by "along with the contents dataset"
  • why do you have to use proc export?

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 756 views
  • 0 likes
  • 3 in conversation