/* Use a data step function RANUNI to generate a random number and format the number with some text to create the unique name. The RAN macro variable will be something like 'A2578900.txt' */ data _null_; numb = ceil (ranuni(0)*10000000); r = 'A' || put(numb, Z7.) || '.txt'; call symput ('ran', r); run; filename foo "c:\temp\&ran"; /* prepend the temp subdirectory */ data _null_; file foo; put 'This is output to a uniquely named file'; run;
/* use pathname function to get work library's path and store in macro variable wpath */ %let wpath=%sysfunc(pathname(work)); /* use wpath macro variable and append filename to it in filename statement */ filename foo "&wpath.\winapi.txt"; data _null_; file foo; put 'This output is going to file in the work subdirectory'; run;
filename foo catalog "work.mytext.foo.source"; data _null_; file foo; put 'This output is going to file in the work catalog'; run;
/*****************************************************************/ /* S A S S A M P L E L I B R A R Y */ /* */ /* NAME: HelloWorld with a twist */ /* TITLE: Hello World */ /* PRODUCT:SAS/IntrNet (Application Dispatcher) */ /* SYSTEM: ALL */ /* KEYS: */ /* PROCS: */ /* DATA: */ /* */ /* SUPPORT: Web Tools Group UPDATE: 20JAN1999 */ /* REF: http://support.sas.com/rnd/web/intrnet/dispatch/ */ /* MISC: */ /*****************************************************************/ /* create macro variable containing the path to the work subdirectory */ %let wpath=%sysfunc(pathname(work)); %put &wpath; filename sascbtbl "&wpath.\winapi.txt"; /* write WINAPI GetUserNameA parameter list to the file for later use */ data _null_; file sascbtbl; input line $char80.; put line $char80.; cards4; routine GetUserNameA minarg=2 maxarg=2 stackpop=called module=advapi32 returns=short; arg 1 char update format=$cstr20; arg 2 num update format=pib4.; ;;;; run; /* Here's the DATA step: Modulen will use the filename sascbtbl for parameter list to the called API */ data _null_; length Name $20.; name=''; Size=20; rc=modulen('GetUserNameA',Name,Size); put rc= Name=; /* Store the current process user name in the macro named vqpname */ call symput('vqpname',name); run; /*simply write out a Web page that says "Hello World!"*/ /* use a DATA step variable and a macro variable in displayed text */ data _null_; /* store macro variable value in data set variable named vname */ vname=symget('vqpname'); file _webout; put '<HTML>'; /* Use data set variable in the output */ put '<HEAD><TITLE>Hello World!' vname ' is running dispatcher! </TITLE></HEAD>'; put '<BODY>'; /* Use macro variable in the output */ put "<H1>Hello World! Your work path is &wpath. vname is &vqpname.</H1>"; put '</BODY>'; put '</HTML>'; run;