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 !!
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;
Unfortunately that's not possible with a simple option.
To generate custom named files you'll need a macro.
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.
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;
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.
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.