<?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: 9.4 Proc Export to txt without REPLACE in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/9-4-Proc-Export-to-txt-without-REPLACE/m-p/399572#M96792</link>
    <description>&lt;P&gt;Wy do I need two (or three) steps? Because I'm a SAS dummy&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 28 Sep 2017 18:00:33 GMT</pubDate>
    <dc:creator>TimWright</dc:creator>
    <dc:date>2017-09-28T18:00:33Z</dc:date>
    <item>
      <title>9.4 Proc Export to txt without REPLACE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/9-4-Proc-Export-to-txt-without-REPLACE/m-p/399550#M96784</link>
      <description>&lt;P&gt;Hi folks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My objective is to create a txt file from a SAS dataset with both the variable names and&amp;nbsp;the data seperated by "^".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My initial strategy was to divide it into two parts: first export a file with only the variable names. Then export the data to the same txt file.&amp;nbsp;&lt;/P&gt;&lt;P&gt;*STEP 1;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;set work.mySASdata;&lt;/P&gt;&lt;P&gt;Retain count 0;count+1;&lt;/P&gt;&lt;P&gt;file "&amp;amp;&lt;SPAN&gt;filelocation";&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;length line $ 200;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;varnameline=strip('var1^var2^var3^var4');&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;if count=1 then put VarnameLine;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;*STEP 2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;proc export data=mySASdata&lt;/P&gt;&lt;P&gt;outfile="&amp;amp;filelocation"&lt;/P&gt;&lt;P&gt;dbms=dlm&amp;nbsp;replace;&lt;/P&gt;&lt;P&gt;delimiter='^';&lt;/P&gt;&lt;P&gt;putnames=no;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is that the second step seems to require the option REPLACE, which would overwrite, rather than append to, the file with only the variable names seperated by ^.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Q1: Is there a way to export SAS9.4 to text without replacement?&lt;/P&gt;&lt;P&gt;Q2: Is there a way to do this in one export or datastep so I won't need an answer to Q1 above?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Tim&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Sep 2017 16:59:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/9-4-Proc-Export-to-txt-without-REPLACE/m-p/399550#M96784</guid>
      <dc:creator>TimWright</dc:creator>
      <dc:date>2017-09-28T16:59:03Z</dc:date>
    </item>
    <item>
      <title>Re: 9.4 Proc Export to txt without REPLACE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/9-4-Proc-Export-to-txt-without-REPLACE/m-p/399557#M96786</link>
      <description>&lt;P&gt;It sounds like you are want to append more than one data set to the exported file.&lt;/P&gt;
&lt;P&gt;If that is the case then you might have to go back to a data _null_ for the follow up data and use the FILE statement option MOD which writes at the end of an existing file if it already exists.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or combine all of the data involved into a single data set and use Proc Export with putnames=yes&lt;/P&gt;</description>
      <pubDate>Thu, 28 Sep 2017 17:16:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/9-4-Proc-Export-to-txt-without-REPLACE/m-p/399557#M96786</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-09-28T17:16:13Z</dc:date>
    </item>
    <item>
      <title>Re: 9.4 Proc Export to txt without REPLACE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/9-4-Proc-Export-to-txt-without-REPLACE/m-p/399565#M96789</link>
      <description>&lt;P&gt;It occurs to me that one 3-step solution would be the following:&lt;/P&gt;&lt;P&gt;STEP1: export SAS data to excel&amp;nbsp;&lt;/P&gt;&lt;P&gt;STEP2: import data from the excel, starting with line 1 (rather than two).The new SAS file, work.NewFile, should have the original variable names as the first record of the data.&lt;/P&gt;&lt;P&gt;STEP3:&lt;/P&gt;&lt;P&gt;Proc Export data=work.NewFile&amp;nbsp;&lt;/P&gt;&lt;P&gt;outfile='c:\newTxtFile.txt'&lt;/P&gt;&lt;P&gt;dbms=dlm&amp;nbsp;replace ;&lt;/P&gt;&lt;P&gt;delimiter='^';&lt;/P&gt;&lt;P&gt;Putnames=No;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Sep 2017 17:35:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/9-4-Proc-Export-to-txt-without-REPLACE/m-p/399565#M96789</guid>
      <dc:creator>TimWright</dc:creator>
      <dc:date>2017-09-28T17:35:32Z</dc:date>
    </item>
    <item>
      <title>Re: 9.4 Proc Export to txt without REPLACE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/9-4-Proc-Export-to-txt-without-REPLACE/m-p/399570#M96791</link>
      <description>&lt;P&gt;Why do you need two steps? The following proc export seems to produce the desired result:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc export data=sashelp.class dbms=dlm file="&amp;amp;filelocation" replace;
   delimiter='^';
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If you don't want/have to print the real variable names, you have two options:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Use one data-null-step.&lt;/LI&gt;&lt;LI&gt;Create a view renaming the variables, then use proc export.&lt;/LI&gt;&lt;/OL&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   set sashelp.class;
   file "&amp;amp;filelocation" delimiter="^";
   
   if _n_ = 1 then do;
      put "Var1^Var2^Var3^Var4^Var5";
   end;
   
   put Name Sex Age Weight Height;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Sep 2017 17:53:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/9-4-Proc-Export-to-txt-without-REPLACE/m-p/399570#M96791</guid>
      <dc:creator>error_prone</dc:creator>
      <dc:date>2017-09-28T17:53:59Z</dc:date>
    </item>
    <item>
      <title>Re: 9.4 Proc Export to txt without REPLACE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/9-4-Proc-Export-to-txt-without-REPLACE/m-p/399572#M96792</link>
      <description>&lt;P&gt;Wy do I need two (or three) steps? Because I'm a SAS dummy&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Sep 2017 18:00:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/9-4-Proc-Export-to-txt-without-REPLACE/m-p/399572#M96792</guid>
      <dc:creator>TimWright</dc:creator>
      <dc:date>2017-09-28T18:00:33Z</dc:date>
    </item>
    <item>
      <title>Re: 9.4 Proc Export to txt without REPLACE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/9-4-Proc-Export-to-txt-without-REPLACE/m-p/399593#M96799</link>
      <description>&lt;P&gt;I cannot believe that I spent so much time trying to figure out an alternative solution based on the assumption that it would export the data in the wrong way, without even testing it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;UGH!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 28 Sep 2017 19:16:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/9-4-Proc-Export-to-txt-without-REPLACE/m-p/399593#M96799</guid>
      <dc:creator>TimWright</dc:creator>
      <dc:date>2017-09-28T19:16:43Z</dc:date>
    </item>
  </channel>
</rss>

