11-23-2016 11:55 AM
I have 800 datasets and i want to export all the datasets into one sheet and not multiple sheet and each dataset has two varaibles
i want both these datasets to write to one excel sheet
Can anyone pls help
11-23-2016 12:48 PM
Am I the only one at work today
Well you can two approaches,
1. union/stack/append your sas tables first, if you don't like the intermedian table, you can opt for sas views, then output to Excel.
2. Do it on the fly, if you have SAS/ACCESS to pc files.
My gut tells me that you are asking for the #2, so here it goes:
LIBNAME OUT XLSX "/your output folder/want.XLSX"; DATA OUT.want; SET table1 table2 .....; RUN; LIBNAME OUT CLEAR ;
If you have 800ish table, then you may want to leverage your meta data, meaning throwing the table names into a macro variable to avoid typing.
11-23-2016 02:15 PM
Two details to add to @Haikuo's suggestion
1) if your dataset names have a common prefix, you can use a dataset list in the set statement: SET TABLE: ;
2) If you want to remember which dataset the rows came from, you can add a third field to the data:
DATA OUT.want; length from $32; SET table: INDSNAME=DS; from = scan(DS, 2, "."); RUN;