06-07-2012 11:17 PM
Is it possible to use the same type of logging options in code as it is when setting the log at the command line? I would like ensure that I have unique log names as my stored process is called frequencies and I have had problems in the past. I know I could create a new variable which I could append to the proc printto log= statement but it would be more convenient to use similar options. Below is a link to the documentation which shows the command line options, precisely the "Details" section.. http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002303556.htm
06-09-2012 11:27 AM
Are you asking how to generate a filename that reflects the current time?
proc printto log="myfile&ts..log";
You can use &SYSDATE9 and &SYSTIME to get the date and time that the SAS session started or use TODAY(),TIME() or DATETIME() to get the current time. You can use formats or string manipulation to pull out whatever parts of the name you want.
I find that when creating filenames using dates it is best to use YYMMDD formats because then the filenames will sort naturally into date order.
06-11-2012 08:39 AM
I agree with Tom. Recently I've been doing date-times with the b8601dt format, which returns yyyymmddThhmmss. (e.g. 20120611T083038 for 8:30 am on June 11 2012.
I'm still new to stored processes. I've been playing with using &_prorgram and &_Username in the name of the file as well, and dumping all my stored process logs in one folder. One caveat is that I think &_username may be a generic value if user is not defined in metadata. Also been thinking about having a standard put statement at the stop of every stored process to write key values to the log (e.g. all user-specified parameters, maybe even just all macro variables). So that later can parse logs to looks for trends in how users invoke different stored processes. Or maybe just append these values to a dataset every time a stored process is invoked....
filename logfile "/logs/%sysfunc(compress(%scan(&_program,-1,/)_&_UserName._%sysfunc(datetime(),b8601dt))).log"; proc printto log=logfile new; run;
06-11-2012 10:47 AM
I have our Stored Process setup as Web Services, these services can get called concurrently by different users and so I was hoping to be able to use the %v option to give each log name a unique name every time. I use a form of the date time currently but I do like the way the b8601dt format displays and will likely to begin using that to make my log names unique.