BookmarkSubscribeRSS Feed
IvyMcKee
Calcite | Level 5

I am trying to use proc export to export a SAS file to excel. The issue is that the file is not something that I created; it existed already in a library accessible via SAS, so I don't know what to call the file I need.

 

Here is what I am doing:

proc export

data= FILE NAME THAT I DON'T KNOW

DBMS = XLSX

Outfile = "place I want the file to go"

replace;

run;

I can see and look at the file I need via the library it is in, but I don't know how to write the file name - if that makes sense? I have copy and pasted the actual file name without any extra library information, and that did not work, and now I am at a loss. This file is pretty deep into a bunch of folders, so the path would be something like "sasApp/folder1/201601/estimate/revision/data/FILE I NEED".

1 REPLY 1
ballardw
Super User

@IvyMcKee wrote:

I am trying to use proc export to export a SAS file to excel. The issue is that the file is not something that I created; it existed already in a library accessible via SAS, so I don't know what to call the file I need.

 

Here is what I am doing:

proc export

data= FILE NAME THAT I DON'T KNOW

DBMS = XLSX

Outfile = "place I want the file to go"

replace;

run;

I can see and look at the file I need via the library it is in, but I don't know how to write the file name - if that makes sense? I have copy and pasted the actual file name without any extra library information, and that did not work, and now I am at a loss. This file is pretty deep into a bunch of folders, so the path would be something like "sasApp/folder1/201601/estimate/revision/data/FILE I NEED".


What is the name of the library? Way to reference SAS data sets is to use Libname.Datasetname. Note that the period between the library name and the data set is required. If your set is in the WORK library then you skip the library if you want to. SAS by default assumes that single names are in the Work library.

 

So your code would look something like:

Proc Export data=somelib.thedataset 
    outfile="c:\path\folder\filename.xlsx"
   dbms = xlsx
   replace
;

You may also find that if you right click on a data set that you get a menu with an EXPORT item that would use a wizard that already knows which set you want to export.

 

The library concept means that SAS code is somewhat operating system independent. Once you have defined a Library in the current operating system syntax then all the SAS code that uses that library knows where to find or place things like data sets.

 

If you do not provide an input data set most SAS procedures that expect an input data set will use the last created set. So it is quite possible that if you did not provide any name that something else gets placed into your exported data file.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 1 reply
  • 534 views
  • 2 likes
  • 2 in conversation