I have been given an opportunity to automate filename assignments for multiple input text files. (Our current "work around" is to manually update every month).
We are using SAS 8.2 in a Windows XP environment.
We have a monthly SAS program that has a "rolling" 18 month set of input files.
So, each month the oldest file (18th) from the previous month rolls off.
We run this process the first week, following the previous month end.
I would like some help in dynamically assigning the 2 character Month and 2 character Year, within the filepath.
I would also like the ability to dynamically assign the Server name, based on the Server the SAS program is executing (Prod = awappp23, Test = dwappt23, Dev = dwappc23); if possible.
Do you have any response to my other need?
(I would also like the ability to dynamically assign the Server name, based on the Server the SAS program is executing (Prod = awappp23, Test = dwappt23, Dev = dwappc23); if possible.)
Can I retrieve the Server Name from some System Variable??
This version uses the windows COMPUTERNAME environment variable. I don't know if that would be server name. Open a command prompt and type "SET" to see all the env variables. There should be one that is server name.
Then use SYSGET to retrieve the value in SAS.
server = sysget('COMPUTERNAME');
length path $256 fileref $8;
do i = 19 to 1 by -1;
prev = intnx('MONTH',today,-i);
path = cats('\\',server,'\f\report store\sasdata\four_',put(prev,mmyyn4.),'.TXT');
fileref = cats('ACN1F',put(i,z2.));
put 'NOTE: ' fileref path;
rc = filename(fileref,path);
filename _all_ list;
Looks like the 'Cats' and 'Filename' functions are not available in my version (8.2). I can use Compress with Concat Pipes.
How can I assign the dynamically created path value to the Filename reference or Infile
You did say 8.2, sorry about that. You can replace cats with || plus compress and or trim. Filename since V6.12 so that is not a problem. Once you get FILEREF and PATH constructed correctly FILENAME function should work.