Hi all --
Here's my problem: I have written a program that is going to be invoked through an html front-end. Meaning, end users will put in their parameters through an html front-end and the program will use those user-defined parameters to generate a customized report. Now, I have to write a section of the code that will output an xls file in the following format "projectname_userID_currentdate_currenttime.xls" My question is: what do I do so that each user has a report generated with his own userID. This is going to be a macro code, but not sure how to go about doing it. I know i will have to define the userid in a separate parameter file, which also includes the other parameters that the program uses. Not sure if I am making myself understood. If somebody can help me with this, it'll be awesome.
If you have macro variables as shown below, then you can build your filename, as shown by the FNAME macro variable (you should be able to submit this code and program and then review the SAS log to see how the &FNAME macro variable was used):
%let pjname = Wombat_;
%let userid = Dorothy_;
%let cdate = %sysfunc(today(),date9.)_;
%let ttime = %sysfunc(time(),time.); /* might not allow : in file names */
%let ctime = %sysfunc(translate(&ttime,_,); /* translate function gets rid of : */
%let userid = abcd; /* I want to link this to an external txt file that will only have a userid. So that whenever that userid changes, it will automatically change the userid in this %let statement and, subsequently, change the userid in the ods html file statement below. All I want to find out is a way to link the above %let staetment to an external file */
ods html file = "/home/e026976/test/&userid..xls";
proc print data=name;
thanks for your help. These small titbits are really helping me expand my SAS knowledge.
Date and time can be generated very easily from SAS functions and formats.
The right user ID may be a little more difficult. Although the SAS session has a "userID" stored in an automatic macro variable &sysUserID, that will probably be different from the identity of the user at the browser.
I assume each user at a browser will have signed into your system in some way, with a userID that will be stored in the whole environment - somewhere - probably as a macro variable, and possibly as an environment variable. The first is easier to discover. In developing your solution, place this code inside a test SAS program you invoke through the browser : [pre] %put _all_; [/pre] You may need to invoke the program wiith one of the _debug_ options that responds with the SAS log. On that SAS log you should see the name of a macro variable whose value is your userID to the browser application.
Given that name, say &app_user, you can construct a file name like [pre] %let datetimes = %sysfunc( datetime(), IS8601DT) ;
%let name = reportX_for&app_user._at_&datetimes..xls ; [/pre]
If the : generated by the IS8601DT datetime format cause invalid filename problems, either compress out the : symbol with: [pre] %let datetimes =%sysfunc( compress( &datetimes, : )); [/pre]or build a datetime picture format that suits your need better, see http://support.sas.com/onlinedoc/913/getDoc/en/proc.hlp/a002473467.htm#a000530223 for details of the date and time features you can use to build your preferred picture format.