The SAS Output Delivery System and reporting techniques

Filename inODS

Super Contributor
Posts: 359

Filename inODS

OK my brain seems to be dead. I am writing a spreadsheet out but I only have a library reference not a path. So if I write a file by datastep I put
Data _null_;
file library(filename);

Now if I want to use ODS I have

ODS excelxp file = ??? ...

using the syntax library(filename) does not work here. How is this accomplished.
Super Contributor
Super Contributor
Posts: 3,174

Re: Filename inODS

The only OS where I have ever seen such FILE statement syntax is z/OS (MVS) where you have a pre-defined JCL DD statement pointing to a PDS or PDSE library, or you have a SAS-defined FILENAME pointing to the library and the member name is placed inside the parentheses. If you have a predefined FILENAME (or an external JCL DD on MVS) and you do not want a PDS (or if it is not an MVS environment), you specify the SAS FILENAME or the FILE statement with the complete file name defined in quotes. And when using ODS, you would specify FILE= parameter.

Scott Barry
SBBWorks, Inc.
Super Contributor
Posts: 359

Re: Filename inODS

> The only OS where I have ever seen such FILE
> statement syntax is z/OS (MVS)
> Scott Barry
> SBBWorks, Inc.

In that case here.

Now back to the question. The environment I am working in assigns the library where the text files are to be placed (which of course changes between Development and Production environments) but not the path for this library. Sure I would change that if I could, and I may have to. But it would be more consistant with the structure I am working in to be able to reference the file by fileref and filename rather than fully qualified name.
Super User
Posts: 10,550

Re: Filename inODS

Not really eligant but you could pull the PATHNAME value from DICTIONARY.LIBNAMES into a macro variable with SQL for the given library.
Super Contributor
Posts: 359

Re: Filename inODS

I was thinking that something like that might be neccessary. I was hoping someone here had the silver bullet for this.
Respected Advisor
Posts: 3,777

Re: Filename inODS

Don't know if this is silver bullet but it seems obvious.

Since the parenthesized file name syntax does not work, don’t use it. You have the FILEREF to the aggregate location so just make a new FILEREF using the information you have plus the file you want to create.

filename FT29F001 '.';

filename FT30F001 "%sysfunc(pathname(FT29F001,F))\dummy.xls";

ods tagsets.excelxp file=FT30F001;
proc print data=sashelp.class;
ods tagsets.excelxp close;
Super Contributor
Posts: 359

Re: Filename inODS


That was exactly what my tired brain was searching for.
Ask a Question
Discussion stats
  • 6 replies
  • 4 in conversation