BookmarkSubscribeRSS Feed
pawan
Obsidian | Level 7


I would like to have piece of code where I can pick data from multiple datasets and load the same into multiple sheets or tabs of one excel file. Please let me know if this is possible using PROC DATASETS. Thanks, Pawan

1 REPLY 1
sam369
Obsidian | Level 7

Hi Pawan,

some one may come with better solution.. Here is the sample Code

/*First sql creating data set name in to macro from work library, if you have in diffrent location change the LIBname*/

proc sql;

select memname into : Ds separated by ' '

from dictionary.columns

where libname='WORK';

quit;

%put &Ds;

%let sqlobs=&sqlobs;

%macro export;

%do i=1 %to &sqlobs;

%let dsn=%scan(&DS,&i);

proc export data=&dsn outfile="\excelpath\sample.xls"

                                 dbms=excel replace;

                                 sheet="&dsn";

run;

%end;

%mend;

%export

Thanks

Sam

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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
  • 1 reply
  • 825 views
  • 0 likes
  • 2 in conversation