BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
WillChia1
Calcite | Level 5

dear all,

 

I am very new to SAS programming. So please pardon me if this is an easy task.

 

I am using SAS EG 7.1, running on a linux server. I have a dataset which i need to split it into individual files by a specific dimension.

In my project, I uses ODS tagset.excelxp, with the function newfile=bygroup.

It is able to split the files into individual dimension value. However, the files name are not descriptive of whats underlying the file.

For eg., currently the files name are like test1.xml, test2.xml, test3.xml etc..

 

how can i rename this dynamically to e.g. storeA.xml, storeB.xml etc.. it will be good if the filename can reference my #byval.. my code looks someething like this:

 

ods listing close;

ods tagsets.excelxp path='<pathname>' file='Store.xml' style=analysis

options(print_header='&L'

sheet_label=' '

sheet_name='#byval1'

embedded_titles='yes'

suppress_bylines='yes'

auto_subtotals='yes'

nobyline='yes')

newfile=bygroup;

 

proc print data=work.stores label noobs split='*';

by stores;

 

title j=l font=calibri h=4 bold 'Store Sales Summary;

 

var x y z;

 

run;

ods listing;

ods tagsets.excelxp close;

 

thanks much for the help !!

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26
proc sql;
  create table loop as select distinct stores from have;
quit;

data _null_;
  set loop;
  call execute(cats('ods tagsets.excelxp file="c:\',stores,'";'));
  call execute(cats('proc print data=have nowd; where stores="',stores,'"; run;'));
  call execute('ods tagsets.excelxp close;');
run;

View solution in original post

3 REPLIES 3
Reeza
Super User

Unfortunately that's not possible with a simple option. 

 

To generate custom named files you'll need a macro. 

Kurt_Bremser
Super User

If you only had to move the raw data, you could use a data step and the filevar= option in the file statement. This allows to create any wanted filename in the data step on the fly.

I even use that method when creating bunches of HTML files for the web server.

RW9
Diamond | Level 26 RW9
Diamond | Level 26
proc sql;
  create table loop as select distinct stores from have;
quit;

data _null_;
  set loop;
  call execute(cats('ods tagsets.excelxp file="c:\',stores,'";'));
  call execute(cats('proc print data=have nowd; where stores="',stores,'"; run;'));
  call execute('ods tagsets.excelxp close;');
run;

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 1349 views
  • 0 likes
  • 4 in conversation