<?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: Convert external txt file to .sas pgm in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/Convert-external-txt-file-to-sas-pgm/m-p/981462#M11532</link>
    <description>&lt;P&gt;The following code is changing all the .TXT files under a fold into .SAS files.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let path_in=  D:\temp\02_table ;  *the pathname for txt files;
%let path_out=  D:\temp\02_table ;  *the pathname for sas files;


filename x pipe "dir &amp;amp;path_in.\*.txt /s /b";
data x;
 infile x truncover;
 input old $2000.;
new=cats(prxchange('s/\w+$//',1,strip(old)),'sas');
rc=rename(strip(old),strip(new),'file');
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And an alternative code by using sas capability: (especially your file name is utf8 encoding)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

/******For UTF-8 编码的文件名***********/
%let path_in= D:\temp\02_table ;  *the pathname for txt files;
%let path_out= D:\temp\02_table ;  *the pathname for sas files;


data _null_;
length fname old new $ 200;
rc=filename('x',"&amp;amp;path_in.");
did=dopen('x');
do i=1 to dnum(did);
 fname=dread(did,i);
 if lowcase(strip(scan(fname,-1,'.')))='txt' then do;
   old=cats("&amp;amp;path_in",'\',fname);
   new=cats(prxchange('s/\w+$//',1,strip(old)),'sas');
   rc=rename(strip(old),strip(new),'file');
 end;
end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 04 Jan 2026 13:44:22 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2026-01-04T13:44:22Z</dc:date>
    <item>
      <title>Convert external txt file to .sas pgm</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Convert-external-txt-file-to-sas-pgm/m-p/981438#M11528</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have a SAS pgm written in legacy SAS that was saved as a txt file.&amp;nbsp; I have imported it to SAS studio, but I cannot find how to convert this txt file to a .sas pgm.&amp;nbsp; Can anyone advise?&amp;nbsp; It is thousands of lines so retyping is not an option.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jan 2026 21:08:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Convert-external-txt-file-to-sas-pgm/m-p/981438#M11528</guid>
      <dc:creator>m852</dc:creator>
      <dc:date>2026-01-02T21:08:38Z</dc:date>
    </item>
    <item>
      <title>Re: Convert external txt file to .sas pgm</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Convert-external-txt-file-to-sas-pgm/m-p/981439#M11529</link>
      <description>&lt;P&gt;No need to "convert" it.&amp;nbsp; Just change its name.&amp;nbsp; SAS/Studio has a RENAME option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For some reason SAS/Studio makes a big deal of the extension used on the filename.&amp;nbsp; Not sure why.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jan 2026 21:24:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Convert-external-txt-file-to-sas-pgm/m-p/981439#M11529</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2026-01-02T21:24:10Z</dc:date>
    </item>
    <item>
      <title>Re: Convert external txt file to .sas pgm</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Convert-external-txt-file-to-sas-pgm/m-p/981440#M11530</link>
      <description>&lt;P&gt;Ah, simple is best. Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jan 2026 21:58:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Convert-external-txt-file-to-sas-pgm/m-p/981440#M11530</guid>
      <dc:creator>m852</dc:creator>
      <dc:date>2026-01-02T21:58:28Z</dc:date>
    </item>
    <item>
      <title>Re: Convert external txt file to .sas pgm</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Convert-external-txt-file-to-sas-pgm/m-p/981461#M11531</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm glad you've got a solution. Marking &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;'s post as the solution makes it easier for others to find if they have a similar question, and it gives him the credit - not that he needs the points in this community!&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":rolling_on_the_floor_laughing:"&gt;🤣&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks &amp;amp; kind regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Sun, 04 Jan 2026 12:16:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Convert-external-txt-file-to-sas-pgm/m-p/981461#M11531</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2026-01-04T12:16:29Z</dc:date>
    </item>
    <item>
      <title>Re: Convert external txt file to .sas pgm</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Convert-external-txt-file-to-sas-pgm/m-p/981462#M11532</link>
      <description>&lt;P&gt;The following code is changing all the .TXT files under a fold into .SAS files.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let path_in=  D:\temp\02_table ;  *the pathname for txt files;
%let path_out=  D:\temp\02_table ;  *the pathname for sas files;


filename x pipe "dir &amp;amp;path_in.\*.txt /s /b";
data x;
 infile x truncover;
 input old $2000.;
new=cats(prxchange('s/\w+$//',1,strip(old)),'sas');
rc=rename(strip(old),strip(new),'file');
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And an alternative code by using sas capability: (especially your file name is utf8 encoding)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

/******For UTF-8 编码的文件名***********/
%let path_in= D:\temp\02_table ;  *the pathname for txt files;
%let path_out= D:\temp\02_table ;  *the pathname for sas files;


data _null_;
length fname old new $ 200;
rc=filename('x',"&amp;amp;path_in.");
did=dopen('x');
do i=1 to dnum(did);
 fname=dread(did,i);
 if lowcase(strip(scan(fname,-1,'.')))='txt' then do;
   old=cats("&amp;amp;path_in",'\',fname);
   new=cats(prxchange('s/\w+$//',1,strip(old)),'sas');
   rc=rename(strip(old),strip(new),'file');
 end;
end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 04 Jan 2026 13:44:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Convert-external-txt-file-to-sas-pgm/m-p/981462#M11532</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2026-01-04T13:44:22Z</dc:date>
    </item>
  </channel>
</rss>

