LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (April 2009, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Tue, 7 Apr 2009 18:07:36 -0400
Reply-To:   Paul Walker <walker.627@OSU.EDU>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Paul Walker <walker.627@OSU.EDU>
Subject:   Re: Get proc printto location
Comments:   To: "Richard A. DeVenezia" <rdevenezia@WILDBLUE.NET>

I'm not sure how robust this is, but the code below might work. If you assume the printto statement assigned a file with .LOG extension and that the filerefs are assigned in chronological order, then it could work. I am not sure about the chronological order assumption, but it seemed to hold true in a few tests.

=========================================

proc printto log="%sysfunc(pathname(Work))\New2.Log" new; run;

data _null_; set sashelp.vextfl; if substr(upcase(strip(reverse(xPath))),1,4)=Reverse('.LOG') then do; call symput('MyLog',xPath); end; run;

proc printto; run;

%put &MyLog;

=========================================

On Tue, 7 Apr 2009 12:57:40 -0700, Richard <rdevenezia@WILDBLUE.NET> wrote:

>On Apr 7, 2:09 pm, walker....@OSU.EDU (Paul Walker) wrote: >> Hi, >> >> I wondered if there is a way to retrieve the currently active proc printto >> location. Here's what I am thinking for a simple illustration: >> >> ======================== >> proc printto log="C:\MyFolder\MyProgram.Log" new; >> run; >> >> %let CurrentPrinttoLog = %GetPrintto; >> %put NOTE: Proc printto is writing to &CurrentPrinttoLog; >> >> proc printto; >> run; >> ========================= >> >> What I would really like to be able to do is get the current location so >> that I can later change it back. For example: >> >> ========================= >> >> * Write to a log; >> proc printto log="C:\MyFolder\MyProgram.Log" new; >> run; >> >> %* Get name of the log file; >> %let CurrentPrinttoLog = %GetPrintto; >> >> %* Write to a new log file; >> proc printto log="C:\MyFolder\Different.Log" new; >> run; >> >> %* Submit whatever code needed; >> put "Hello"; >> >> %* Reset printto location; >> proc printto; >> run; >> >> %* Resume writing to the first log; >> proc printto log="&CurrentPrinttoLog"; >> run; >> >> ========================= > >Paul: > >I don't think there is an easy way. The SQL DICTIONARY.EXTFILES >enumeration will list a file opened by syntax > Proc PRINTTO log='c:\temp\mylog.txt'; >because the proc makes an 'automatic' #LN fileref for the quoted os- >path. >However, you don't which of the enumeration the Proc opened. > >Furthermore, if a fileref is used, > filename mylog 'c:\temp\mylog.txt'; *or; > filename mylog catalog 'work.logs.one.log'; > proc printto log=mylog; >the fileref will of course show up in the extfiles enumeration, but >extfiles has no columns reporting 'activity'. > >-------- >filename mylog 'c:\temp\sas-printto.txt'; >filename mylog catalog 'work.logs.one.log'; > >* proc printto log='c:\temp\sas-printto.txt'; >proc printto log=mylog new; >run; > >ods listing close; >ods html file='c:\temp\extfiles.html' style=journal; > >title "PrintTo log=file"; > >%put _all_; > >proc sql; >* select * from dictionary.dictionaries; > select * from dictionary.extfiles; >quit; > >proc printto log=log; >run; > >title "PrintTo log=log"; > >proc sql; >* select * from dictionary.dictionaries; > select * from dictionary.extfiles; >quit; > >ods html close; >-------- > >Richard A. DeVenezia >http://www.devenezia.com


Back to: Top of message | Previous page | Main SAS-L page