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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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