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?

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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
  • 878 views
  • 0 likes
  • 3 in conversation