<?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: File name automation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/File-name-automation/m-p/56505#M12086</link>
    <description>Hi Lu,&lt;BR /&gt;
  How to make the index search which is not case sensitive?&lt;BR /&gt;
if index(name,'GH Utilization') then do;&lt;BR /&gt;
sas code&lt;BR /&gt;
end;&lt;BR /&gt;
here 'GH Utilization' can be in any case..upper, lower ,mixed or Prop case.</description>
    <pubDate>Fri, 04 Sep 2009 14:39:29 GMT</pubDate>
    <dc:creator>SASPhile</dc:creator>
    <dc:date>2009-09-04T14:39:29Z</dc:date>
    <item>
      <title>File name automation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/File-name-automation/m-p/56472#M12053</link>
      <description>The excel file names that we recieve every month  are not consistent.This forces me to manually change the file name and then process them in SAS.&lt;BR /&gt;
Is there a way to change the file name programatically?&lt;BR /&gt;
Say for example , If the file contains "AETNA" , the file name is changed to AETNA_06_2009 for the current month and also the tab is changed  the same as file name, hence  the SAS dataset name is same as the tab.&lt;BR /&gt;
Thanks for the help in advance.</description>
      <pubDate>Fri, 17 Jul 2009 17:26:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/File-name-automation/m-p/56472#M12053</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2009-07-17T17:26:45Z</dc:date>
    </item>
    <item>
      <title>Re: File name automation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/File-name-automation/m-p/56473#M12054</link>
      <description>data steps or macros are the usual choice for deriving things like this. Should be able to find examples in online doc as well as among Samples in &lt;A href="http://support.sas.com" target="_blank"&gt;http://support.sas.com&lt;/A&gt;.&lt;BR /&gt;
 &lt;BR /&gt;
good luck&lt;BR /&gt;
PeterC</description>
      <pubDate>Sun, 19 Jul 2009 09:59:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/File-name-automation/m-p/56473#M12054</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2009-07-19T09:59:20Z</dc:date>
    </item>
    <item>
      <title>Re: File name automation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/File-name-automation/m-p/56474#M12055</link>
      <description>For this objective, the use of SAS functions like INTNX, SYMPUT (using CALL from a DATA step), and possibly the special-purpose %SYSFUNC (macro language call - permits you to integrate DATA step function calls) come to mind with either / both SAS DATA step and MACRO programming techniques.  &lt;BR /&gt;
&lt;BR /&gt;
As mentioned in this thread, the SAS support website can offer both SAS-hosted documentation but more importantly the supplemental technical / conference papers on this type of topic -- explore the site using the SEARCH facility for code automation (topic: using SAS code to generate SAS code) examples.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Sun, 19 Jul 2009 15:31:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/File-name-automation/m-p/56474#M12055</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-07-19T15:31:34Z</dc:date>
    </item>
    <item>
      <title>Re: File name automation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/File-name-automation/m-p/56475#M12056</link>
      <description>Hi SASPhile &lt;BR /&gt;
&lt;BR /&gt;
This simple code will help you &lt;BR /&gt;
&lt;BR /&gt;
%let my_dir=e:\my_excel_files;&lt;BR /&gt;
filename dir pipe "dir &amp;amp;my_dir";&lt;BR /&gt;
&lt;BR /&gt;
data d;&lt;BR /&gt;
infile dir pad truncover;&lt;BR /&gt;
input date $10.@;&lt;BR /&gt;
if date ='' or date='Volume' or length(date) &amp;lt;10 then  delete;&lt;BR /&gt;
else input  time $ ampm $ dir $ name $20.;&lt;BR /&gt;
if trim(dir)='&lt;DIR&gt;' then delete;&lt;BR /&gt;
if index(name,'AETNA') then&lt;BR /&gt;
   do;&lt;BR /&gt;
    nm=scan(name ,1,'.'); &lt;BR /&gt;
    cmd="ren &amp;amp;my_dir\"||trim(left(name)) ||' '||compress(left(nm)||put(month(today()),z2.)||'_'||year(today())||'.xls') ;&lt;BR /&gt;
    put cmd=;&lt;BR /&gt;
    rc=system(cmd);&lt;BR /&gt;
   end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
lu&lt;/DIR&gt;</description>
      <pubDate>Mon, 20 Jul 2009 07:06:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/File-name-automation/m-p/56475#M12056</guid>
      <dc:creator>lu</dc:creator>
      <dc:date>2009-07-20T07:06:28Z</dc:date>
    </item>
    <item>
      <title>Re: File name automation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/File-name-automation/m-p/56476#M12057</link>
      <description>I will add the following to lu's code for the tab renaming issue, (explanation bellow).&lt;BR /&gt;
&lt;BR /&gt;
Note1: assumes a &amp;amp;FILENAME macro has the renamed filename without extension (say=AETNA_06_2009).&lt;BR /&gt;
Note2: assumes that the original name of the worksheet to be renamed is "Sheet1".&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
options noxsync noxwait xmin; * assynchronous execution;&lt;BR /&gt;
&lt;BR /&gt;
* start Excel DDE server;&lt;BR /&gt;
x 'excel.exe'; /* you may need to add the full path */&lt;BR /&gt;
&lt;BR /&gt;
filename xlfile dde 'excel|system';&lt;BR /&gt;
data _null_;&lt;BR /&gt;
file xlfile; * start DDE connection and open desired workbook;&lt;BR /&gt;
put '[OPEN("&lt;DIR&gt;\&amp;amp;FILENAME..xls")]'; /* replace with your &lt;DIR&gt; */&lt;BR /&gt;
put '[WORKBOOK.NEXT()]';&lt;BR /&gt;
put '[WORKBOOK.INSERT(3)]'; * insert new macro worksheet;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
* prepare macro for worksheet renaming;&lt;BR /&gt;
filename xlmacro dde 'excel|Macro1!r1c1:r2c1' notab;&lt;BR /&gt;
data _null_;&lt;BR /&gt;
file xlmacro;&lt;BR /&gt;
* write macro code;&lt;BR /&gt;
put '=WORKBOOK.NAME("Sheet1","&amp;amp;FILENAME")';&lt;BR /&gt;
put '=HALT(TRUE)';&lt;BR /&gt;
put '!dde_flush';&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
* rename worksheet by running macro;&lt;BR /&gt;
data _null_;&lt;BR /&gt;
file xlfile;&lt;BR /&gt;
put '[RUN("Macro1!r1c1")]';&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
* delete macro worksheet;&lt;BR /&gt;
filename xlmacro clear;&lt;BR /&gt;
data _null_;&lt;BR /&gt;
file xlfile;&lt;BR /&gt;
put '[WORKBOOK.ACTIVATE("Macro1")]';&lt;BR /&gt;
put '[ERROR(FALSE)]';&lt;BR /&gt;
put '[WORKBOOK.DELETE()]';&lt;BR /&gt;
put '[ERROR(TRUE)]';&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
This is a known workaround for a knowned DDE problem (function WORKBOOK.NAME("old_name", "new_name") not working properly when evoked through the DDE engine). &lt;BR /&gt;
Trick is to create a new worksheet (Macro1) and write there the macro code for the worksheet renaming. Then execute it. Then delete it.&lt;BR /&gt;
&lt;BR /&gt;
Check Koen Vyverman's SAS paper about DDE:&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi27/p190-27.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi27/p190-27.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
Cheers from Portugal.&lt;BR /&gt;
&lt;BR /&gt;
Daniel Santos @ &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;.&lt;/DIR&gt;&lt;/DIR&gt;</description>
      <pubDate>Mon, 20 Jul 2009 10:55:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/File-name-automation/m-p/56476#M12057</guid>
      <dc:creator>DanielSantos</dc:creator>
      <dc:date>2009-07-20T10:55:40Z</dc:date>
    </item>
    <item>
      <title>Re: File name automation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/File-name-automation/m-p/56477#M12058</link>
      <description>Lu,&lt;BR /&gt;
does this change the name of the file physically?&lt;BR /&gt;
cmd="ren &amp;amp;my_dir\"||trim(left(name)) ||' '||compress(left(nm)||put(month(today()),z2.)||'_'||year(today())||'.xls') ;</description>
      <pubDate>Tue, 21 Jul 2009 20:26:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/File-name-automation/m-p/56477#M12058</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2009-07-21T20:26:04Z</dc:date>
    </item>
    <item>
      <title>Re: File name automation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/File-name-automation/m-p/56478#M12059</link>
      <description>Hi,&lt;BR /&gt;
This is character string contain command 'rename...' .&lt;BR /&gt;
to run  command on OS - rc=system(cmd);.&lt;BR /&gt;
And this is change the name of the file physically&lt;BR /&gt;
&lt;BR /&gt;
lu</description>
      <pubDate>Wed, 22 Jul 2009 05:16:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/File-name-automation/m-p/56478#M12059</guid>
      <dc:creator>lu</dc:creator>
      <dc:date>2009-07-22T05:16:35Z</dc:date>
    </item>
    <item>
      <title>Re: File name automation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/File-name-automation/m-p/56479#M12060</link>
      <description>I tried using this and did not change the name physically!</description>
      <pubDate>Wed, 22 Jul 2009 13:43:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/File-name-automation/m-p/56479#M12060</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2009-07-22T13:43:05Z</dc:date>
    </item>
    <item>
      <title>Re: File name automation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/File-name-automation/m-p/56480#M12061</link>
      <description>Hi.&lt;BR /&gt;
&lt;BR /&gt;
Try this macro (if you work under Windows)&lt;BR /&gt;
&lt;BR /&gt;
  %macro rename(input=d:\work\test rename,m=06,y=2009);&lt;BR /&gt;
  %let dlm=\;&lt;BR /&gt;
  %let filrf=mydir;&lt;BR /&gt;
  %let rc=%sysfunc(filename(filrf,"&amp;amp;input"));&lt;BR /&gt;
  %let did=%sysfunc(dopen(&amp;amp;filrf));&lt;BR /&gt;
  %let lstname=;&lt;BR /&gt;
   %let memcount=%sysfunc(dnum(&amp;amp;did));&lt;BR /&gt;
  %if &amp;amp;memcount &amp;gt; 0 %then %do;&lt;BR /&gt;
  %do i=1 %to &amp;amp;memcount;&lt;BR /&gt;
  %let lstname=%sysfunc(dread(&amp;amp;did,&amp;amp;i));&lt;BR /&gt;
  %let file=&amp;amp;input&amp;amp;dlm&amp;amp;lstname;&lt;BR /&gt;
   %if %sysfunc(index(&amp;amp;lstname,AETNA)) ne 0&lt;BR /&gt;
   %then %do;&lt;BR /&gt;
   x move "&amp;amp;file" "&amp;amp;input&amp;amp;dlm.AETNA_&amp;amp;m._&amp;amp;y";&lt;BR /&gt;
   %end;&lt;BR /&gt;
  %end;&lt;BR /&gt;
  %let rc=%sysfunc(dclose(&amp;amp;did));&lt;BR /&gt;
  %end;&lt;BR /&gt;
  %mend rename;&lt;BR /&gt;
&lt;BR /&gt;
  options mprint symbolgen noxwait;&lt;BR /&gt;
  %rename;</description>
      <pubDate>Wed, 22 Jul 2009 14:10:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/File-name-automation/m-p/56480#M12061</guid>
      <dc:creator>Oleg_L</dc:creator>
      <dc:date>2009-07-22T14:10:06Z</dc:date>
    </item>
    <item>
      <title>Re: File name automation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/File-name-automation/m-p/56481#M12062</link>
      <description>Sorry.&lt;BR /&gt;
I forgot upcase checking and xls extension for out:&lt;BR /&gt;
&lt;BR /&gt;
  %macro rename(input=d:\work\test rename,m=06,y=2009);&lt;BR /&gt;
  %let dlm=\;&lt;BR /&gt;
  %let filrf=mydir;&lt;BR /&gt;
  %let rc=%sysfunc(filename(filrf,"&amp;amp;input"));&lt;BR /&gt;
  %let did=%sysfunc(dopen(&amp;amp;filrf));&lt;BR /&gt;
  %let lstname=;&lt;BR /&gt;
   %let memcount=%sysfunc(dnum(&amp;amp;did));&lt;BR /&gt;
  %if &amp;amp;memcount &amp;gt; 0 %then %do;&lt;BR /&gt;
  %do i=1 %to &amp;amp;memcount;&lt;BR /&gt;
  %let lstname=%sysfunc(dread(&amp;amp;did,&amp;amp;i));&lt;BR /&gt;
  %let file=&amp;amp;input&amp;amp;dlm&amp;amp;lstname;&lt;BR /&gt;
   %if %sysfunc(index(%sysfunc(upcase(&amp;amp;lstname)),AETNA)) ne 0&lt;BR /&gt;
   %then %do;&lt;BR /&gt;
   x move "&amp;amp;file" "&amp;amp;input&amp;amp;dlm.AETNA_&amp;amp;m._&amp;amp;y..xls";&lt;BR /&gt;
   %end;&lt;BR /&gt;
  %end;&lt;BR /&gt;
  %let rc=%sysfunc(dclose(&amp;amp;did));&lt;BR /&gt;
  %end;&lt;BR /&gt;
  %mend rename;&lt;BR /&gt;
&lt;BR /&gt;
  options mprint symbolgen noxwait;&lt;BR /&gt;
  %rename;</description>
      <pubDate>Wed, 22 Jul 2009 14:42:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/File-name-automation/m-p/56481#M12062</guid>
      <dc:creator>Oleg_L</dc:creator>
      <dc:date>2009-07-22T14:42:50Z</dc:date>
    </item>
    <item>
      <title>Re: File name automation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/File-name-automation/m-p/56482#M12063</link>
      <description>SASPhile,&lt;BR /&gt;
pls let me to know:&lt;BR /&gt;
1.do you use Windows or Unix/Linux OS?&lt;BR /&gt;
2.What do you see in LOG after statement    put cmd=;  ?&lt;BR /&gt;
3.chek in data set d variable RC = ???&lt;BR /&gt;
&lt;BR /&gt;
lu</description>
      <pubDate>Wed, 22 Jul 2009 17:59:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/File-name-automation/m-p/56482#M12063</guid>
      <dc:creator>lu</dc:creator>
      <dc:date>2009-07-22T17:59:26Z</dc:date>
    </item>
    <item>
      <title>Re: File name automation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/File-name-automation/m-p/56483#M12064</link>
      <description>I use windows.&lt;BR /&gt;
This is the code I used.&lt;BR /&gt;
&lt;BR /&gt;
The input file present in my_dir is:&lt;BR /&gt;
2009 June GH Utilization - Unblinded.xls&lt;BR /&gt;
My objective is 2009 June GH Utilization  is present &lt;BR /&gt;
then chnage the file name to caremark_2009_07.xls&lt;BR /&gt;
and the tab to caremark_2009_07.&lt;BR /&gt;
&lt;BR /&gt;
 %let my_dir=C:\Documents and Settings\skap\Desktop\inpt;&lt;BR /&gt;
filename dir pipe "dir &amp;amp;my_dir";&lt;BR /&gt;
&lt;BR /&gt;
data d;&lt;BR /&gt;
infile dir pad truncover;&lt;BR /&gt;
input date $10.@;&lt;BR /&gt;
if date ='' or date='Volume' or length(date) &amp;lt;10 then delete;&lt;BR /&gt;
else input time $ ampm $ dir $ name $20.;&lt;BR /&gt;
if trim(dir)='&lt;DIR&gt;' then delete;&lt;BR /&gt;
if index(name,'GH Utilization') then&lt;BR /&gt;
do;&lt;BR /&gt;
nm=scan(name ,1,'.'); &lt;BR /&gt;
cmd="ren &amp;amp;my_dir\"||trim(left(name)) ||' '||compress(left(nm)||put(month(today()),z2.)||'_'||year(today())||'.xls') ;&lt;BR /&gt;
put cmd=;&lt;BR /&gt;
rc=system(cmd);&lt;BR /&gt;
end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
The log is:&lt;BR /&gt;
&lt;BR /&gt;
623   %let my_dir=C:\Documents and Settings\skap\Desktop\inpt;&lt;BR /&gt;
624  filename dir pipe "dir &amp;amp;my_dir";&lt;BR /&gt;
625&lt;BR /&gt;
626  data d;&lt;BR /&gt;
627  infile dir pad truncover;&lt;BR /&gt;
628  input date $10.@;&lt;BR /&gt;
629  if date ='' or date='Volume' or length(date) &amp;lt;10 then delete;&lt;BR /&gt;
630  else input time $ ampm $ dir $ name $20.;&lt;BR /&gt;
631  if trim(dir)='&lt;DIR&gt;' then delete;&lt;BR /&gt;
632  if index(name,'GH Utilization') then&lt;BR /&gt;
633  do;&lt;BR /&gt;
634  nm=scan(name ,1,'.');&lt;BR /&gt;
635  cmd="ren &amp;amp;my_dir\"||trim(left(name)) ||'&lt;BR /&gt;
635! '||compress(left(nm)||put(month(today()),z2.)||'_'||year(today())||'.xls') ;&lt;BR /&gt;
636  put cmd=;&lt;BR /&gt;
637  rc=system(cmd);&lt;BR /&gt;
638  end;&lt;BR /&gt;
639  run;&lt;BR /&gt;
&lt;BR /&gt;
NOTE: Numeric values have been converted to character values at the places given by:&lt;BR /&gt;
      (Line):(Column).&lt;BR /&gt;
      635:94&lt;BR /&gt;
NOTE: The infile DIR is:&lt;BR /&gt;
      Unnamed Pipe Access Device,&lt;BR /&gt;
      PROCESS=dir C:\Documents and Settings\skap\Desktop\inpt,&lt;BR /&gt;
      RECFM=V,LRECL=256&lt;BR /&gt;
&lt;BR /&gt;
Stderr output:&lt;BR /&gt;
The system cannot find the path specified.&lt;BR /&gt;
NOTE: 0 records were read from the infile DIR.&lt;BR /&gt;
NOTE: The data set WORK.D has 0 observations and 8 variables.&lt;BR /&gt;
NOTE: DATA statement used (Total process time):&lt;BR /&gt;
      real time           0.10 seconds&lt;BR /&gt;
      cpu time            0.01 seconds&lt;/DIR&gt;&lt;/DIR&gt;</description>
      <pubDate>Wed, 22 Jul 2009 18:12:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/File-name-automation/m-p/56483#M12064</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2009-07-22T18:12:37Z</dc:date>
    </item>
    <item>
      <title>Re: File name automation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/File-name-automation/m-p/56484#M12065</link>
      <description>ok ,&lt;BR /&gt;
the problem is blanks in path - C:\Documents and Settings\skap\Desktop\inpt;&lt;BR /&gt;
try something without blank -  c:\inpt; . If you must this path  I will fix it tomorrow&lt;BR /&gt;
I haven't access to SAS Windows  now .&lt;BR /&gt;
&lt;BR /&gt;
lu</description>
      <pubDate>Wed, 22 Jul 2009 18:41:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/File-name-automation/m-p/56484#M12065</guid>
      <dc:creator>lu</dc:creator>
      <dc:date>2009-07-22T18:41:31Z</dc:date>
    </item>
    <item>
      <title>Re: File name automation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/File-name-automation/m-p/56485#M12066</link>
      <description>thank you !</description>
      <pubDate>Wed, 22 Jul 2009 19:10:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/File-name-automation/m-p/56485#M12066</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2009-07-22T19:10:42Z</dc:date>
    </item>
    <item>
      <title>Re: File name automation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/File-name-automation/m-p/56486#M12067</link>
      <description>Hi ,SASPhile, Fixed code: &lt;BR /&gt;
options noxwait;&lt;BR /&gt;
%let my_dir=C:\Documents and Settings\skap\Desktop\inpt;&lt;BR /&gt;
data _null_;&lt;BR /&gt;
 dir_cmd='dir "'||"&amp;amp;my_dir"||'"';&lt;BR /&gt;
 rc=filename('dir',dir_cmd,'pipe');&lt;BR /&gt;
 run;&lt;BR /&gt;
data d;&lt;BR /&gt;
infile dir pad truncover;&lt;BR /&gt;
input date $10.@;&lt;BR /&gt;
if date ='' or date='Volume' or length(date) &amp;lt;10 then  delete;&lt;BR /&gt;
else input  time $ ampm $ dir $ name $200.;&lt;BR /&gt;
if trim(dir)='&lt;DIR&gt;' then delete;&lt;BR /&gt;
if index(name,'GH Utilization') then&lt;BR /&gt;
   do;&lt;BR /&gt;
    nm='caremark'; &lt;BR /&gt;
    cmd='ren "'||"&amp;amp;my_dir\"||trim(left(name)) ||'" "'||compress(left(nm)||'_'||year(today())||'_'||put(month(today()),z2.)||'.xls"') ;&lt;BR /&gt;
    put cmd=;&lt;BR /&gt;
    rc=system(cmd);&lt;BR /&gt;
   end;&lt;BR /&gt;
run;&lt;BR /&gt;
lu.

Message was edited by: lu&lt;/DIR&gt;</description>
      <pubDate>Thu, 23 Jul 2009 07:50:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/File-name-automation/m-p/56486#M12067</guid>
      <dc:creator>lu</dc:creator>
      <dc:date>2009-07-23T07:50:19Z</dc:date>
    </item>
    <item>
      <title>Re: File name automation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/File-name-automation/m-p/56487#M12068</link>
      <description>put cmd=;&lt;BR /&gt;
    rc=system(cmd);&lt;BR /&gt;
   end;&lt;BR /&gt;
run;&lt;BR /&gt;
lu.&lt;BR /&gt;
&lt;BR /&gt;
P.S bug in forum ??? cut my previous message

Message was edited by: lu</description>
      <pubDate>Thu, 23 Jul 2009 07:55:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/File-name-automation/m-p/56487#M12068</guid>
      <dc:creator>lu</dc:creator>
      <dc:date>2009-07-23T07:55:55Z</dc:date>
    </item>
    <item>
      <title>Re: File name automation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/File-name-automation/m-p/56488#M12069</link>
      <description>Thanks Lu!</description>
      <pubDate>Thu, 23 Jul 2009 14:47:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/File-name-automation/m-p/56488#M12069</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2009-07-23T14:47:35Z</dc:date>
    </item>
    <item>
      <title>Re: File name automation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/File-name-automation/m-p/56489#M12070</link>
      <description>Question.&lt;BR /&gt;
How to change the tab name?</description>
      <pubDate>Thu, 23 Jul 2009 18:26:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/File-name-automation/m-p/56489#M12070</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2009-07-23T18:26:04Z</dc:date>
    </item>
    <item>
      <title>Re: File name automation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/File-name-automation/m-p/56490#M12071</link>
      <description>What about Daniel Santos's answer ?&lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/message.jspa?messageID=23303#23303" target="_blank"&gt;http://support.sas.com/forums/message.jspa?messageID=23303#23303&lt;/A&gt;&lt;BR /&gt;
lu</description>
      <pubDate>Thu, 23 Jul 2009 20:47:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/File-name-automation/m-p/56490#M12071</guid>
      <dc:creator>lu</dc:creator>
      <dc:date>2009-07-23T20:47:34Z</dc:date>
    </item>
    <item>
      <title>Re: File name automation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/File-name-automation/m-p/56491#M12072</link>
      <description>Hi Daniel,&lt;BR /&gt;
 I used your code in the bottom half(comments added) and it throws an error:&lt;BR /&gt;
The top part is working fine.It chages the file name.The tab should be changed to &lt;BR /&gt;
what ever value is passed to nm_2009_month (in this case nm='Pharmacare';)&lt;BR /&gt;
Pharmacare_2009_06.&lt;BR /&gt;
error shown in the end of the code:&lt;BR /&gt;
&lt;BR /&gt;
options noxwait;&lt;BR /&gt;
%let my_dir=C:\Documents and Settings\skap\Desktop\inpt;&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
 dir_cmd='dir "'||"&amp;amp;my_dir"||'"';&lt;BR /&gt;
 rc=filename('dir',dir_cmd,'pipe');&lt;BR /&gt;
 run;&lt;BR /&gt;
&lt;BR /&gt;
data d;&lt;BR /&gt;
infile dir pad truncover;&lt;BR /&gt;
input date $10.@;&lt;BR /&gt;
if date ='' or date='Volume' or length(date) &amp;lt;10 then  delete;&lt;BR /&gt;
else input  time $ ampm $ dir $ name $200.;&lt;BR /&gt;
if trim(dir)='&lt;DIR&gt;' then delete;&lt;BR /&gt;
if index(name,'Norditropin Pharmacare') then&lt;BR /&gt;
  do;&lt;BR /&gt;
   nm='Pharmacare';&lt;BR /&gt;
   cmd='ren "'||"&amp;amp;my_dir\"||trim(left(name)) ||'" "'||compress(left(nm)||'_'||year(today())||'_'||put(month(today()),z2.)||'.xls"') ;&lt;BR /&gt;
   put cmd=;&lt;BR /&gt;
   rc=system(cmd);&lt;BR /&gt;
  end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
/*** Daniel's code starts here ***/&lt;BR /&gt;
* start Excel DDE server;&lt;BR /&gt;
x 'C:\Documents and Settings\skap\Desktop\inpt'; /* you may need to add the full path */&lt;BR /&gt;
&lt;BR /&gt;
filename xlfile dde 'excel|system';&lt;BR /&gt;
data _null_;&lt;BR /&gt;
file xlfile; * start DDE connection and open desired workbook;&lt;BR /&gt;
put '[OPEN("&amp;amp;my_dir.\&amp;amp;FILENAME..xls")]'; /* replace with your &lt;DIR&gt; */&lt;BR /&gt;
put '[WORKBOOK.NEXT()]';&lt;BR /&gt;
put '[WORKBOOK.INSERT(3)]'; * insert new macro worksheet;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
* prepare macro for worksheet renaming;&lt;BR /&gt;
filename xlmacro dde 'excel|Macro1!r1c1:r2c1' notab;&lt;BR /&gt;
data _null_;&lt;BR /&gt;
file xlmacro;&lt;BR /&gt;
* write macro code;&lt;BR /&gt;
put '=WORKBOOK.NAME("Sheet1","&amp;amp;FILENAME")';&lt;BR /&gt;
put '=HALT(TRUE)';&lt;BR /&gt;
put '!dde_flush';&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
* rename worksheet by running macro;&lt;BR /&gt;
data _null_;&lt;BR /&gt;
file xlfile;&lt;BR /&gt;
put '[RUN("Macro1!r1c1")]';&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
* delete macro worksheet;&lt;BR /&gt;
filename xlmacro clear;&lt;BR /&gt;
data _null_;&lt;BR /&gt;
file xlfile;&lt;BR /&gt;
put '[WORKBOOK.ACTIVATE("Macro1")]';&lt;BR /&gt;
put '[ERROR(FALSE)]';&lt;BR /&gt;
put '[WORKBOOK.DELETE()]';&lt;BR /&gt;
put '[ERROR(TRUE)]';&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
ERROR: Physical file does not exist, excel|system.&lt;/DIR&gt;&lt;/DIR&gt;</description>
      <pubDate>Fri, 24 Jul 2009 18:30:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/File-name-automation/m-p/56491#M12072</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2009-07-24T18:30:05Z</dc:date>
    </item>
  </channel>
</rss>

