BookmarkSubscribeRSS Feed
alepage
Barite | Level 11

Hello,

 

I would like to have more information on two things.

First:

Filename dest1 temp;

 

THE TEMP DEVICE


The TEMP device allows you to create a temporary file that exists only as long as the filename is assigned. There are
many reasons why you would need to use a temporary file in a SAS program. But is it possible to see the content of that file with SAS EG ?

 

Also, another statement that I saw on the web is:

 

"%sysfunc(getoption(WORK))/filename"

 

ex:  "%sysfunc(getoption(WORK))/directories.json"

 

My understanding is that a file directories.json is created into the work library but is it possible to see it ? What are the advantages and disadvantages of these temporary files.

 

Thanks to improve my knowledges.

 

 

3 REPLIES 3
Kurt_Bremser
Super User

If you want to see the contents of such a file you can always do

data _null_;
infile dest1;
input;
put _infile_;
run;

and read the log.

But such a temporary file has always been created by the current process, so the owner of the process MUST positively know what he/she put in there 😉

PaigeMiller
Diamond | Level 26

@alepage wrote:

Hello,

 

I would like to have more information on two things.

First:

Filename dest1 temp;

 

THE TEMP DEVICE


The TEMP device allows you to create a temporary file that exists only as long as the filename is assigned. There are
many reasons why you would need to use a temporary file in a SAS program. But is it possible to see the content of that file with SAS EG ?

 

 


Since you have created the filename, and since you know what is written into that filename (because you have written the program), you should know what is in there. You can also look at what is in there exactly the same as you would look for files in any filename. You didn't quote enough of the documentation, which also says "Files manipulated by the TEMP device can have the same attributes and behave identically to DISK files."

 

"%sysfunc(getoption(WORK))/filename"

 

ex: "%sysfunc(getoption(WORK))/directories.json"

 

The commands above have to be part of a longer SAS command, as by itself "%sysfunc(getoption(WORK))/filename" is meaningless. Please provide context here.

 

--
Paige Miller
yabwon
Amethyst | Level 16

"What are the advantages and disadvantages of these temporary files."

Advantage - they are temporary.

Disadvantage - they are temporary.

 

If you have:

 

Filename dest1 temp;

run:

 

Filename dest1 LIST;

and see the log.

 

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1422 views
  • 1 like
  • 4 in conversation