<?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: Exporting to text file in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-to-text-file/m-p/996#M480</link>
    <description>Hi:&lt;BR /&gt;
 Your X command does not need to be in a DATA _NULL_ program. You may need to investigate some of the options that affect the X command, (NOXWAIT and NOXSYNC)&lt;BR /&gt;
 &lt;BR /&gt;
 However, this is not really an ODS or BASE Reporting procedure question. The SAS companion for your operating system gives different ways to execute statements in command or exec file.&lt;BR /&gt;
&lt;BR /&gt;
  For example, if I wanted to have SAS issue an X command to start Word from within a SAS session (sort of a silly example), I could do this (note that there is no data step program in this code at all):&lt;BR /&gt;
[pre]&lt;BR /&gt;
options noxwait noxsync;&lt;BR /&gt;
x 'C:\Program~1\Micros~2\Office\winword.exe';&lt;BR /&gt;
[/pre]&lt;BR /&gt;
or, if I want to clean up a file before I start my program, I can do this:&lt;BR /&gt;
[pre]&lt;BR /&gt;
x 'del c:\temp\oldfile.txt';&lt;BR /&gt;
 [/pre]&lt;BR /&gt;
Your best bet for help with this question is to read the documentation for examples of the X command or to contact Tech Support for more help.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
[/pre]</description>
    <pubDate>Mon, 25 Feb 2008 16:34:50 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2008-02-25T16:34:50Z</dc:date>
    <item>
      <title>Exporting to text file</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-to-text-file/m-p/991#M475</link>
      <description>Hi All,&lt;BR /&gt;
I trying to produce a list report to text file which displays all variables and getting formatted. &lt;BR /&gt;
I can do it with proc print. &lt;BR /&gt;
Foexample;&lt;BR /&gt;
proc print data=murti;&lt;BR /&gt;
    var name surname job birth;&lt;BR /&gt;
run;&lt;BR /&gt;
Result output;&lt;BR /&gt;
/******************************************************&lt;BR /&gt;
 name surname job birth&lt;BR /&gt;
  .      .     .&lt;BR /&gt;
  .      .     .&lt;BR /&gt;
  .      .     .&lt;BR /&gt;
******************************************************/&lt;BR /&gt;
But when I define length and format it isn't seems same rows;&lt;BR /&gt;
forexample:&lt;BR /&gt;
&lt;BR /&gt;
proc print data=murti;&lt;BR /&gt;
    format name surname job $50. birth 4.;           &lt;BR /&gt;
    var name surname job birth;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Result Output;&lt;BR /&gt;
/****************************************************&lt;BR /&gt;
  name surname&lt;BR /&gt;
   .      .&lt;BR /&gt;
   .      .&lt;BR /&gt;
   .      .&lt;BR /&gt;
&lt;BR /&gt;
 job   birth&lt;BR /&gt;
  .       .&lt;BR /&gt;
  .       .&lt;BR /&gt;
  .       .&lt;BR /&gt;
&lt;BR /&gt;
How can I see this values in same rows?&lt;BR /&gt;
I have to export only like *.txt,&lt;BR /&gt;
Best regards,</description>
      <pubDate>Thu, 06 Jul 2006 10:34:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-to-text-file/m-p/991#M475</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2006-07-06T10:34:47Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting to text file</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-to-text-file/m-p/992#M476</link>
      <description>With PROC PRINT or any of the procedures, you are limited to what can be written to a single line by the maximum line size which is 256. You can try to increase the line size with the LS= system option. If you need more than 256, then you can use DATA _null_ with the FILE/PUT statements.</description>
      <pubDate>Thu, 06 Jul 2006 13:52:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-to-text-file/m-p/992#M476</guid>
      <dc:creator>Chevell_sas</dc:creator>
      <dc:date>2006-07-06T13:52:00Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting to text file</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-to-text-file/m-p/993#M477</link>
      <description>Here's an example of using the FILE statement and DATA _NULL_ -- you can write columns that will "line up" or formatted by using column pointer control in the PUT statement to explicitly place every character/byte in the .txt file:&lt;BR /&gt;
[pre]&lt;B&gt;&lt;BR /&gt;
data _null_;&lt;BR /&gt;
  set sashelp.class;&lt;BR /&gt;
  file 'c:\temp\class.txt';&lt;BR /&gt;
  if _n_ = 1 then do;&lt;BR /&gt;
    ** write out column names;&lt;BR /&gt;
    put @1 "Name"&lt;BR /&gt;
       @15 "Age"&lt;BR /&gt;
      @25 "Height";&lt;BR /&gt;
  end;&lt;BR /&gt;
  ** write out every obs;&lt;BR /&gt;
  put @1 name $char15.&lt;BR /&gt;
      @15 age 3.0&lt;BR /&gt;
      @25 height 5.2;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;/B&gt;[/pre]&lt;BR /&gt;
&lt;BR /&gt;
after this program runs, you can open class.txt in Notepad and see the columns line up (as long as the Notepad font is set to Courier -- if you use a proportional font to view, then the columns will not look lined up.)&lt;BR /&gt;
cynthia</description>
      <pubDate>Thu, 06 Jul 2006 16:37:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-to-text-file/m-p/993#M477</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2006-07-06T16:37:07Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting to text file</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-to-text-file/m-p/994#M478</link>
      <description>Perfect, thank you! Cynthia</description>
      <pubDate>Fri, 07 Jul 2006 05:59:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-to-text-file/m-p/994#M478</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2006-07-07T05:59:42Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting to text file</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-to-text-file/m-p/995#M479</link>
      <description>Hi all,&lt;BR /&gt;
&lt;BR /&gt;
how can I write entries to the external file if the text contains spaces and/or special character? I have to copy/delete external files on our SAS-Server with paths like "\\sasserver\filedir" and filenames containing blanks i.e. "File 1.csv"?&lt;BR /&gt;
&lt;BR /&gt;
I tried:&lt;BR /&gt;
&lt;BR /&gt;
%let docopy=docopy.bat;&lt;BR /&gt;
data _null_;&lt;BR /&gt;
 file docopy notitles  noprint lrecl=1000;&lt;BR /&gt;
&lt;BR /&gt;
  statement = 'copy '||&amp;amp;fromdir.||&amp;amp;copyfile.||' &amp;amp;todir.';&lt;BR /&gt;
  put @1 statement;&lt;BR /&gt;
run;&lt;BR /&gt;
data _null_;&lt;BR /&gt;
 x &amp;amp;docopy.;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
But SAS wont write the file...&lt;BR /&gt;
&lt;BR /&gt;
Thx in advance,&lt;BR /&gt;
Tom</description>
      <pubDate>Mon, 25 Feb 2008 14:22:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-to-text-file/m-p/995#M479</guid>
      <dc:creator>tbatliner</dc:creator>
      <dc:date>2008-02-25T14:22:21Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting to text file</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-to-text-file/m-p/996#M480</link>
      <description>Hi:&lt;BR /&gt;
 Your X command does not need to be in a DATA _NULL_ program. You may need to investigate some of the options that affect the X command, (NOXWAIT and NOXSYNC)&lt;BR /&gt;
 &lt;BR /&gt;
 However, this is not really an ODS or BASE Reporting procedure question. The SAS companion for your operating system gives different ways to execute statements in command or exec file.&lt;BR /&gt;
&lt;BR /&gt;
  For example, if I wanted to have SAS issue an X command to start Word from within a SAS session (sort of a silly example), I could do this (note that there is no data step program in this code at all):&lt;BR /&gt;
[pre]&lt;BR /&gt;
options noxwait noxsync;&lt;BR /&gt;
x 'C:\Program~1\Micros~2\Office\winword.exe';&lt;BR /&gt;
[/pre]&lt;BR /&gt;
or, if I want to clean up a file before I start my program, I can do this:&lt;BR /&gt;
[pre]&lt;BR /&gt;
x 'del c:\temp\oldfile.txt';&lt;BR /&gt;
 [/pre]&lt;BR /&gt;
Your best bet for help with this question is to read the documentation for examples of the X command or to contact Tech Support for more help.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
[/pre]</description>
      <pubDate>Mon, 25 Feb 2008 16:34:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-to-text-file/m-p/996#M480</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2008-02-25T16:34:50Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting to text file</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-to-text-file/m-p/997#M481</link>
      <description>Hi cynthia,&lt;BR /&gt;
&lt;BR /&gt;
thx for the fast reply. I just managed to solve my problem:&lt;BR /&gt;
[pre]&lt;BR /&gt;
%let vgbatfile=copyvgfiles.bat;&lt;BR /&gt;
&lt;BR /&gt;
filename vgbat "J:\temp\&amp;amp;vgbatfile.";&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
 file vgbat lrecl=1000;&lt;BR /&gt;
&lt;BR /&gt;
  statement = 'move "'|| "&amp;amp;fromdir."|| '\'|| trim("&amp;amp;fromFilename.")||'" "'||"&amp;amp;todir."||'"';&lt;BR /&gt;
  put statement @;&lt;BR /&gt;
 &lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
filename vgbat pipe "J:\temp\&amp;amp;vgbatfile.";&lt;BR /&gt;
data _null_;&lt;BR /&gt;
	infile vgbat ;&lt;BR /&gt;
	input;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
I think the "trick" was to use the correct "put" statement with the "@" at the end.&lt;BR /&gt;
&lt;BR /&gt;
Best regards,&lt;BR /&gt;
Tom</description>
      <pubDate>Mon, 25 Feb 2008 16:49:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-to-text-file/m-p/997#M481</guid>
      <dc:creator>tbatliner</dc:creator>
      <dc:date>2008-02-25T16:49:30Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting to text file</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-to-text-file/m-p/998#M482</link>
      <description>Hi:&lt;BR /&gt;
  I'm glad that worked for you. But I'm still baffled why your BAT file needs to be in a DATA step. I just double checked and my test BAT file executes just fine like this:&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
filename copylist 'c:\temp\mycopylist.bat';&lt;BR /&gt;
** copy and add zz in front of the new file name;&lt;BR /&gt;
** if you want to run this, change my FROM and TO and my filenames;&lt;BR /&gt;
     &lt;BR /&gt;
data _null_;&lt;BR /&gt;
length fromfile tofile $200 fromdir todir fname $100;&lt;BR /&gt;
  infile datalines;&lt;BR /&gt;
  input fromdir $ todir $ fname $;&lt;BR /&gt;
  fromfile = catt(fromdir,'\',fname);&lt;BR /&gt;
  tofile = catt(todir,'\zz',fname);&lt;BR /&gt;
  file copylist;&lt;BR /&gt;
  if _n_ = 1 then put 'echo off';&lt;BR /&gt;
  put @1 'copy ' fromfile tofile;&lt;BR /&gt;
return;&lt;BR /&gt;
datalines;&lt;BR /&gt;
c:\temp c:\temp\mydata kermit.jpg&lt;BR /&gt;
c:\temp c:\temp\mydata myanswers.doc&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
    &lt;BR /&gt;
filename copylist clear;&lt;BR /&gt;
   &lt;BR /&gt;
* Then issue the X command *;&lt;BR /&gt;
options noxwait noxsync;&lt;BR /&gt;
 x 'c:\temp\mycopylist.bat';[/pre]&lt;BR /&gt;
&lt;BR /&gt;
But there's always more than one way to do something with SAS...so I learned something new today!&lt;BR /&gt;
  &lt;BR /&gt;
cynthia</description>
      <pubDate>Mon, 25 Feb 2008 19:16:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-to-text-file/m-p/998#M482</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2008-02-25T19:16:09Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting to text file</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-to-text-file/m-p/999#M483</link>
      <description>Thank you everone here, i have learn something from this topic.</description>
      <pubDate>Wed, 27 Feb 2008 05:16:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-to-text-file/m-p/999#M483</guid>
      <dc:creator>Black</dc:creator>
      <dc:date>2008-02-27T05:16:01Z</dc:date>
    </item>
  </channel>
</rss>

