BookmarkSubscribeRSS Feed
Flip
Fluorite | Level 6
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.
6 REPLIES 6
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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.
Flip
Fluorite | Level 6
> The only OS where I have ever seen such FILE
> statement syntax is z/OS (MVS)
>
> Scott Barry
> SBBWorks, Inc.

In that case here.

http://support.sas.com/documentation/cdl/en/hostunx/61879/HTML/default/specaggs.htm

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.
ballardw
Super User
Not really eligant but you could pull the PATHNAME value from DICTIONARY.LIBNAMES into a macro variable with SQL for the given library.
Flip
Fluorite | Level 6
I was thinking that something like that might be neccessary. I was hoping someone here had the silver bullet for this.
data_null__
Jade | Level 19
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.

[pre]
filename FT29F001 '.';

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

ods tagsets.excelxp file=FT30F001;
proc print data=sashelp.class;
run;
ods tagsets.excelxp close;
[/pre]
Flip
Fluorite | Level 6
Poifect.

That was exactly what my tired brain was searching for.

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