<?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 dataset to txt file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Convert-dataset-to-txt-file/m-p/105081#M258442</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would guess that it was simply how you defined it.&amp;nbsp; The following works for me and should for you:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set sashelp.class ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; _filename=cats("c:\art\",name,"_",age)||'.txt';&lt;/P&gt;&lt;P&gt;&amp;nbsp; file dummy filevar=_filename ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; put variable3 ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 20 Dec 2012 23:08:00 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2012-12-20T23:08:00Z</dc:date>
    <item>
      <title>Convert dataset to txt file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-dataset-to-txt-file/m-p/105078#M258439</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to convert a sas data set to a .txt file.&amp;nbsp; This seems to be fairly straightforward if I wanted to convert the set into a single text file, but I need each observation to be exported to its own.txt file and have data from two of the variables being the .txt file names.&lt;/P&gt;&lt;P&gt;So if here is my data set:&lt;/P&gt;&lt;P&gt;variable 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; variable 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; variable 3&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y&lt;/P&gt;&lt;P&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; c&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; z&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to create 3 text files, 1_a.txt, 2_b.txt and 3_c.txt, containing x, y, z in the text file, respectably. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've heard this can be done with a sas macro, but I am not familiar with how to write macros and don't know where to start. Any help would be appreciated!&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Dec 2012 01:48:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-dataset-to-txt-file/m-p/105078#M258439</guid>
      <dc:creator>cloudforest</dc:creator>
      <dc:date>2012-12-20T01:48:13Z</dc:date>
    </item>
    <item>
      <title>Re: Convert dataset to txt file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-dataset-to-txt-file/m-p/105079#M258440</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use the FILEVAR option on the FILE statement and you can do it in a single data step without any macro code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data _null_;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; set have ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; _filename=catx('_',variable1,variable2)||'.txt';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; file dummy filevar=_filename ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; put variable3 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Dec 2012 02:41:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-dataset-to-txt-file/m-p/105079#M258440</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-12-20T02:41:50Z</dc:date>
    </item>
    <item>
      <title>Re: Convert dataset to txt file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-dataset-to-txt-file/m-p/105080#M258441</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using this code, how can I specify the directory I want the txt files to be exported to? When I tried to insert a path to a folder after the file option, I get the error message "A Physical file reference (ie PHYSICAL FILE REFERENCE") or an aggregate file storage reference (ie AGGREGATE(MEMBER)) reference cannot be used with the FILEVAR=option.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Dec 2012 22:14:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-dataset-to-txt-file/m-p/105080#M258441</guid>
      <dc:creator>cloudforest</dc:creator>
      <dc:date>2012-12-20T22:14:39Z</dc:date>
    </item>
    <item>
      <title>Re: Convert dataset to txt file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-dataset-to-txt-file/m-p/105081#M258442</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would guess that it was simply how you defined it.&amp;nbsp; The following works for me and should for you:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set sashelp.class ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; _filename=cats("c:\art\",name,"_",age)||'.txt';&lt;/P&gt;&lt;P&gt;&amp;nbsp; file dummy filevar=_filename ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; put variable3 ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Dec 2012 23:08:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-dataset-to-txt-file/m-p/105081#M258442</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-12-20T23:08:00Z</dc:date>
    </item>
    <item>
      <title>Re: Convert dataset to txt file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-dataset-to-txt-file/m-p/105082#M258443</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It works! Thank you both so much for your help! &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Dec 2012 00:30:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-dataset-to-txt-file/m-p/105082#M258443</guid>
      <dc:creator>cloudforest</dc:creator>
      <dc:date>2012-12-21T00:30:27Z</dc:date>
    </item>
    <item>
      <title>Re: Convert dataset to txt file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-dataset-to-txt-file/m-p/105083#M258444</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;beware&lt;/STRONG&gt; if your data step might write to the same file more than once and the data are not in "filevar" order.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I found the file seemed to be closed when the filevar value changed.&lt;/P&gt;&lt;P&gt;A second write to the file over-wrote the first, if the data are not in "filevar" order.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but here for CLOUDFOREST, it should not be a problem because only one row should be written to each file&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 22 Dec 2012 10:15:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-dataset-to-txt-file/m-p/105083#M258444</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2012-12-22T10:15:33Z</dc:date>
    </item>
  </channel>
</rss>

