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;
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;
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;
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.
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.
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
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;
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
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/
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.