<?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: Importing invalid SAS dataset names and exporting as .dta files in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Importing-invalid-SAS-dataset-names-and-exporting-as-dta-files/m-p/347831#M80446</link>
    <description>&lt;P&gt;Two questions: 1. You use the macro variable &amp;amp;folder, but don't show the code that created that macro variable and&lt;/P&gt;
&lt;P&gt;2. validvarname=any doesn't apply to SAS dataset names. They CAN'T begin with a number or include any special characters (other than an underscore).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would guess that the files were either renamed, or created by a program outside of SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My suggestion would be to write a program that renames the files, keeping them as is, but beginning with an underscore. Then you should be able to export them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 06 Apr 2017 16:47:26 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2017-04-06T16:47:26Z</dc:date>
    <item>
      <title>Importing invalid SAS dataset names and exporting as .dta files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-invalid-SAS-dataset-names-and-exporting-as-dta-files/m-p/347805#M80435</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to import 79 different SAS datasets and export them as .dta files. Part of the issue I am having is that the .sas7bdat file names are not valid SAS dataset names--they contain only numeric characters.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried to write code that would at least import one dataset and save it out as a .dta and then create a loop to go through the rest of the SAS datasets, but I cannot even get past the first step.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let folder = C:\Example folder;&lt;BR /&gt;&lt;BR /&gt;proc printto log="&amp;amp;folder.\SAS files\Logs\01 Convert SAS files to dta.log" new; 
run;

libname sasinput	"&amp;amp;folder.\Natives";

options validvarname=any;

proc export data=sasinput.01095552 outfile= "&amp;amp;folder.\SAS files\Output\01095552.dta" REPLACE;
run;

proc printto;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;It seems from researching that I need to specify the system option validvarname=any but it does not appear that I am specifying it correctly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looking to loop through SAS datasets sequentially numbered beginning with&amp;nbsp;01095552.sas7bdat and ending with&amp;nbsp;01095630.sas7bdat. I am having a lot of trouble figuring out what I am doing wrong.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for any help. If you could not tell I am fairly inexperienced&amp;nbsp;with SAS, although I have a lot of STATA experience.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2017 16:54:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-invalid-SAS-dataset-names-and-exporting-as-dta-files/m-p/347805#M80435</guid>
      <dc:creator>mjcochran</dc:creator>
      <dc:date>2017-04-06T16:54:10Z</dc:date>
    </item>
    <item>
      <title>Re: Importing invalid SAS dataset names and exporting as .dta files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-invalid-SAS-dataset-names-and-exporting-as-dta-files/m-p/347831#M80446</link>
      <description>&lt;P&gt;Two questions: 1. You use the macro variable &amp;amp;folder, but don't show the code that created that macro variable and&lt;/P&gt;
&lt;P&gt;2. validvarname=any doesn't apply to SAS dataset names. They CAN'T begin with a number or include any special characters (other than an underscore).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would guess that the files were either renamed, or created by a program outside of SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My suggestion would be to write a program that renames the files, keeping them as is, but beginning with an underscore. Then you should be able to export them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2017 16:47:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-invalid-SAS-dataset-names-and-exporting-as-dta-files/m-p/347831#M80446</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-04-06T16:47:26Z</dc:date>
    </item>
    <item>
      <title>Re: Importing invalid SAS dataset names and exporting as .dta files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-invalid-SAS-dataset-names-and-exporting-as-dta-files/m-p/347840#M80448</link>
      <description>&lt;P&gt;Hi Art,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, forgot to copy the line of code that generates the macro variable &amp;amp;folder in my post above (fixed now).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Renaming the files makes my code work. Would've liked to have avoided it, but thankfully isn't a big deal in the end. Thanks for the help!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2017 17:11:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-invalid-SAS-dataset-names-and-exporting-as-dta-files/m-p/347840#M80448</guid>
      <dc:creator>mjcochran</dc:creator>
      <dc:date>2017-04-06T17:11:28Z</dc:date>
    </item>
  </channel>
</rss>

