BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jiangmi
Calcite | Level 5

Hi, All,

I am trying to debug a program and want to take a close look into the fileref contents.

For example: In the following codes, certain info was written into 'lst_out' when 'proc print' was executed.

Is there any way I can know what is in the 'lst_out'?

Thanks.

data have;

var=123;

run;

filename lst_out temp;

proc printto new print = lst_out ; run;

proc print data=have;

run;

proc printto;

run;

/* check if fileref "lst_out" exist?  No = 0 */  

data a;  

exist=fexist ("lst_out");  

put;

put "Fileref curdirfl exist? " exist=;  

run;

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

Since it was defined as a temporary file, depending upon how your system is setup, the file might only be viewable during the session when the code was run.

It is a text file that is written to your work directory. On Windows, you can open it with any text editor, but it will have a randomly assigned name.

During the active session you can find out where the file was written by running:

%let pgmpath = %sysfunc(pathname(lst_out));

%put &pgmpath;

View solution in original post

9 REPLIES 9
art297
Opal | Level 21

Since it was defined as a temporary file, depending upon how your system is setup, the file might only be viewable during the session when the code was run.

It is a text file that is written to your work directory. On Windows, you can open it with any text editor, but it will have a randomly assigned name.

During the active session you can find out where the file was written by running:

%let pgmpath = %sysfunc(pathname(lst_out));

%put &pgmpath;

jiangmi
Calcite | Level 5

To Arthur,

I am running EG on server, and after run the codes

%let pgmpath = %sysfunc(pathname(lst_out));

%put &pgmpath;

, I got this path in the log

/SASWork/SAS_workA48102BC003A_ualbsasapp1/#LN00093

So, How to locate this file and maybe open it (what kind of format is it)?

Thanks.

art297
Opal | Level 21

I'm not sufficiently familiar with EG to provide any advice. The path you received is the direct path to the file but, depending upon your site's EG settings, the file and directory might be deleted as soon as the run completes.

It is just a text file, although it might contain some printer-specific codes, like page change, etc.

If there is a way for you to print a txt file while you are in EG, the file shown in the path is the one you'd want to print.

ScottBass
Rhodochrosite | Level 12

If you're running EG on the remote server, then SAS is your "portal" to the server, unless you can remote login to the server (i.e. RDP for Windows or Putty for Unix).

However, if all you're wanting to do is see the contents of the file for debugging purposes, then this should work:

data have;

var=123;

run;

filename lst_out temp;

proc printto new print = lst_out ; run;

proc print data=have;

run;

proc printto;

run;

data _null_;

infile lst_out;

input;

putlog _infile_;

run;

I'm not in front of EG right now, but there may be a task to copy a remote file to your local system, analogous to FTP.

HTH,

Scott


Please post your question as a self-contained data step in the form of "have" (source) and "want" (desired results).
I won't contribute to your post if I can't cut-and-paste your syntactically correct code into SAS.
Tom
Super User Tom
Super User

Use the PATHNAME() function to get the physical name to pass to the FILEEXIST() function.

filename test1 temp;

data _null_;

  exist=fileexist(pathname('test1')) ;

  put exist=;

run;

ods _all_ close;

ods listing file=test1 ;

proc print data=sashelp.class ; run;

ods listing close;

ods listing;

data _null_;

  exist=fileexist(pathname('test1')) ;

  put exist=;

run;

jiangmi
Calcite | Level 5

Hi, ALL,

Thanks for your inputs.

Your codes work if I run SAS on my computer.

However, I still have no idea where to find it if it is run on the server.

But by checking what is going on inside the local computer I know what to do next.

Thanks.

Joe

Tom
Super User Tom
Super User

Not sure I understand the question here.  What reason do you want to look at the file?  And if you want to look at it why are you making it as a temporary file?  

Perhaps what you want is to use the upload/download custom task that Chris has blogged about.

http://blogs.sas.com/content/sasdummy/2013/11/25/11-custom-tasks/

jiangmi
Calcite | Level 5

Yeah, You are right, Tom. I can make it a permanent file so that I can look at it easily. should have done that earlier. Thanks for reminding me. I will also read the blog you shared. Thank you.

Basically, I am debugging a macro written by somebody else. The problem is: There is a macro variable in the macro. The macro variable is created from the temp fileref. This particular macro variable will only resolve if you run the macro two or more batches together. For example:

if you do

% themac (data1);

it will not resolve for data1.

if you do

% themac (data1);

% themac (data2);

% themac (data3);

it will resolve correctly for data2 and data3, but not for data1.

The only way to get it resolved for data1 is to change the order of the runs, like,

% themac (data2);

% themac (data1);

% themac (data3);

In this case, again it will not resolve for data2.

I will keep working on this issue recently. I don't have a sample macro to show this problem yet. I may make one later and ask for extra help here.

jiangmi
Calcite | Level 5

Hi, ALL,

I was able to see the output information in the fileref. Now, the follow-up question was posted out at:

Nothing was delivered out for the 1st run for some reason.

Pls take a look at the post and give opinions if you can. Thanks.

Joe

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 9 replies
  • 3270 views
  • 8 likes
  • 4 in conversation