<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Global Variable Dynamic Assignments in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Global-Variable-Dynamic-Assignments/m-p/54836#M11650</link>
    <description>I had something else set up incorrectly....Now it all works as recommended.&lt;BR /&gt;
Kudos!!</description>
    <pubDate>Thu, 16 Oct 2008 19:17:52 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2008-10-16T19:17:52Z</dc:date>
    <item>
      <title>Global Variable Dynamic Assignments</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Global-Variable-Dynamic-Assignments/m-p/54830#M11644</link>
      <description>Hi All,&lt;BR /&gt;
&lt;BR /&gt;
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).&lt;BR /&gt;
&lt;BR /&gt;
We are using SAS 8.2 in a Windows XP environment.&lt;BR /&gt;
&lt;BR /&gt;
We have a monthly SAS program that has a "rolling" 18 month set of input files.&lt;BR /&gt;
So, each month the oldest file (18th) from the previous month rolls off.&lt;BR /&gt;
We run this process the first week, following the previous month end.&lt;BR /&gt;
I would like some help in dynamically assigning the 2 character Month and 2 character Year, within the filepath.&lt;BR /&gt;
&lt;BR /&gt;
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.&lt;BR /&gt;
 &lt;BR /&gt;
&lt;U&gt;Here are the existing FileName references used for September 2008 Monthend:&lt;/U&gt;&lt;BR /&gt;
filename ACN1F19     '\\awappp23\f\report store\sasdata\four_0307.TXT';&lt;BR /&gt;
filename ACN1F18     '\\awappp23\f\report store\sasdata\four_0407.TXT';&lt;BR /&gt;
filename ACN1F17     '\\awappp23\f\report store\sasdata\four_0507.TXT';&lt;BR /&gt;
filename ACN1F16     '\\awappp23\f\report store\sasdata\four_0607.TXT';&lt;BR /&gt;
filename ACN1F15     '\\awappp23\f\report store\sasdata\four_0707.TXT';&lt;BR /&gt;
filename ACN1F14     '\\awappp23\f\report store\sasdata\four_0807.TXT';&lt;BR /&gt;
filename ACN1F13     '\\awappp23\f\report store\sasdata\four_0907.TXT';&lt;BR /&gt;
filename ACN1F12     '\\awappp23\f\report store\sasdata\four_1007.TXT';&lt;BR /&gt;
filename ACN1F11     '\\awappp23\f\report store\sasdata\four_1107.TXT';&lt;BR /&gt;
filename ACN1F10     '\\awappp23\f\report store\sasdata\four_1207.TXT';&lt;BR /&gt;
filename ACN1F09     '\\awappp23\f\report store\sasdata\four_0108.TXT';&lt;BR /&gt;
filename ACN1F08     '\\awappp23\f\report store\sasdata\four_0208.TXT';&lt;BR /&gt;
filename ACN1F07     '\\awappp23\f\report store\sasdata\four_0308.TXT';&lt;BR /&gt;
filename ACN1F06     '\\awappp23\f\report store\sasdata\four_0408.TXT';&lt;BR /&gt;
filename ACN1F05     '\\awappp23\f\report store\sasdata\four_0508.TXT';&lt;BR /&gt;
filename ACN1F04     '\\awappp23\f\report store\sasdata\four_0608.TXT';&lt;BR /&gt;
filename ACN1F03     '\\awappp23\f\report store\sasdata\four_0708.TXT';&lt;BR /&gt;
filename ACN1F02     '\\awappp23\f\report store\sasdata\four_0808.TXT';&lt;BR /&gt;
filename ACN1F01     '\\awappp23\e\report store\sasdata\four_0908.TXT';&lt;BR /&gt;
&lt;BR /&gt;
I can get the current date from the system, but how do I perform arithmetic to subtract the Month and Year values for each preceeding filename?&lt;BR /&gt;
Any Ideas??</description>
      <pubDate>Thu, 16 Oct 2008 15:58:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Global-Variable-Dynamic-Assignments/m-p/54830#M11644</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-10-16T15:58:19Z</dc:date>
    </item>
    <item>
      <title>Re: Global Variable Dynamic Assignments</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Global-Variable-Dynamic-Assignments/m-p/54831#M11645</link>
      <description>You can use INTNX function and MMYYN format.  You could also use FILENAME function in the same data step to allocate the file name instead of writing FILENAME statements. &lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data _null_;&lt;BR /&gt;
   today=today();&lt;BR /&gt;
   length path $256 fileref $8;&lt;BR /&gt;
   do i = 19 to 1 by -1;&lt;BR /&gt;
      prev = intnx('MONTH',today,-i);&lt;BR /&gt;
      path = cats('\\awappp23\f\report store\sasdata\four_',put(prev,mmyyn4.),'.TXT');&lt;BR /&gt;
      fileref = cats('ACN1F',put(i,z2.));&lt;BR /&gt;
      put 'NOTE: ' fileref path;&lt;BR /&gt;
      rc = filename(fileref,path);&lt;BR /&gt;
      end;&lt;BR /&gt;
   run;&lt;BR /&gt;
filename _all_ list;&lt;BR /&gt;
[pre]</description>
      <pubDate>Thu, 16 Oct 2008 16:29:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Global-Variable-Dynamic-Assignments/m-p/54831#M11645</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2008-10-16T16:29:47Z</dc:date>
    </item>
    <item>
      <title>Re: Global Variable Dynamic Assignments</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Global-Variable-Dynamic-Assignments/m-p/54832#M11646</link>
      <description>Great suggestion.&lt;BR /&gt;
&lt;BR /&gt;
Do you have any response to my other need?&lt;BR /&gt;
(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.)&lt;BR /&gt;
&lt;BR /&gt;
Can I retrieve the Server Name from some System Variable??</description>
      <pubDate>Thu, 16 Oct 2008 17:14:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Global-Variable-Dynamic-Assignments/m-p/54832#M11646</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-10-16T17:14:35Z</dc:date>
    </item>
    <item>
      <title>Re: Global Variable Dynamic Assignments</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Global-Variable-Dynamic-Assignments/m-p/54833#M11647</link>
      <description>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.&lt;BR /&gt;
&lt;BR /&gt;
Then use SYSGET to retrieve the value in SAS.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data _null_;&lt;BR /&gt;
   today=today();&lt;BR /&gt;
   server = sysget('COMPUTERNAME');&lt;BR /&gt;
   length path $256 fileref $8;&lt;BR /&gt;
   do i = 19 to 1 by -1;&lt;BR /&gt;
      prev = intnx('MONTH',today,-i);&lt;BR /&gt;
      path = cats('\\',server,'\f\report store\sasdata\four_',put(prev,mmyyn4.),'.TXT');&lt;BR /&gt;
      fileref = cats('ACN1F',put(i,z2.));&lt;BR /&gt;
      put 'NOTE: ' fileref path;&lt;BR /&gt;
      rc = filename(fileref,path);&lt;BR /&gt;
      end;&lt;BR /&gt;
   run;&lt;BR /&gt;
filename _all_ list;&lt;BR /&gt;
&lt;BR /&gt;
[pre]</description>
      <pubDate>Thu, 16 Oct 2008 18:07:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Global-Variable-Dynamic-Assignments/m-p/54833#M11647</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2008-10-16T18:07:23Z</dc:date>
    </item>
    <item>
      <title>Re: Global Variable Dynamic Assignments</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Global-Variable-Dynamic-Assignments/m-p/54834#M11648</link>
      <description>Looks like the 'Cats' and 'Filename' functions are not available in my version (8.2).  I can use Compress with Concat Pipes.&lt;BR /&gt;
How can I assign the dynamically created path value to the Filename reference or Infile</description>
      <pubDate>Thu, 16 Oct 2008 18:23:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Global-Variable-Dynamic-Assignments/m-p/54834#M11648</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-10-16T18:23:09Z</dc:date>
    </item>
    <item>
      <title>Re: Global Variable Dynamic Assignments</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Global-Variable-Dynamic-Assignments/m-p/54835#M11649</link>
      <description>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.&lt;BR /&gt;
&lt;BR /&gt;
Did you find the server name?</description>
      <pubDate>Thu, 16 Oct 2008 18:38:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Global-Variable-Dynamic-Assignments/m-p/54835#M11649</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2008-10-16T18:38:00Z</dc:date>
    </item>
    <item>
      <title>Re: Global Variable Dynamic Assignments</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Global-Variable-Dynamic-Assignments/m-p/54836#M11650</link>
      <description>I had something else set up incorrectly....Now it all works as recommended.&lt;BR /&gt;
Kudos!!</description>
      <pubDate>Thu, 16 Oct 2008 19:17:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Global-Variable-Dynamic-Assignments/m-p/54836#M11650</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-10-16T19:17:52Z</dc:date>
    </item>
  </channel>
</rss>

