<?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: delimeted file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/delimeted-file/m-p/343626#M78908</link>
    <description>&lt;P&gt;First of all, provide sample data. Use the macro from &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; to convert (part of) your dataset to a datastep that can be posted here ({i} or "little running man" icon).&lt;/P&gt;
&lt;P&gt;I'm particularly intrigued by the fact that 31/03/2016 is treated by Excel once as a date and once as text, so I suspect there's something special in the data.&lt;/P&gt;</description>
    <pubDate>Thu, 23 Mar 2017 09:13:30 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2017-03-23T09:13:30Z</dc:date>
    <item>
      <title>delimeted file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delimeted-file/m-p/343612#M78900</link>
      <description>&lt;P&gt;Why when I output my data into delimeted textfile, the date are not right/left justified. Some in left position, some in right position. How to make it in right justified for all.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="110"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="110"&gt;12/4/2016&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;31/03/2016&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;31/03/2016&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;9/12/2008&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;12/1/2009&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Thu, 23 Mar 2017 07:52:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delimeted-file/m-p/343612#M78900</guid>
      <dc:creator>Hhh111</dc:creator>
      <dc:date>2017-03-23T07:52:32Z</dc:date>
    </item>
    <item>
      <title>Re: delimeted file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delimeted-file/m-p/343613#M78901</link>
      <description>&lt;P&gt;Provide sample code which illustrates the issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The table you've posted indicates that you're looking at your textfile via Excel. Don't do that! Excel might do "stuff" to your data. Use a text editor like Notepad++ to examine how your data got written out.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2017 08:27:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delimeted-file/m-p/343613#M78901</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-03-23T08:27:35Z</dc:date>
    </item>
    <item>
      <title>Re: delimeted file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delimeted-file/m-p/343616#M78903</link>
      <description>&lt;P&gt;Tq for the reply Mr Patrick.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The sample code as per below&lt;/P&gt;
&lt;P&gt;DATA _NULL_;&lt;BR /&gt;SET A.TRY;&lt;BR /&gt;FILE "C:\Testing Data\ACCOUNT&amp;amp;REPTDT..txt" DLM='|'; &lt;BR /&gt;IF _N_ EQ 1 THEN PUT @1 'DATE|ACCTNO|NAME|';&lt;BR /&gt;put DATE ACCTNO NAME;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;currently the date is in DDMMYY10. format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And yes, to view the file, I open up with Excel. I never try use Notepad as I want it to be viewed in Excel (as per request from boss).&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2017 08:38:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delimeted-file/m-p/343616#M78903</guid>
      <dc:creator>Hhh111</dc:creator>
      <dc:date>2017-03-23T08:38:25Z</dc:date>
    </item>
    <item>
      <title>Re: delimeted file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delimeted-file/m-p/343619#M78904</link>
      <description>&lt;P&gt;For us to replicate the issue you will need to provide some sample data for&amp;nbsp;&lt;SPAN&gt;SET A.TRY;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best provide a SAS data step which creates this data.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Even if your end goal is to open the data in Excel you still need to use a text editor and not Excel to look into&amp;nbsp;the created text file. Excel won't tell you what's not working and doesn't show you the text file as it really looks like.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;From what I can tell: Some of the date strings in your text file get interpreted as Dates by Excel and others get interpreted as text strings (that's most likely the explanation for the left/right alignments). WHY that's happening is something you need to investigate by looking at the actual text file without changing it - that's what a text editor does for you.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2017 08:47:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delimeted-file/m-p/343619#M78904</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-03-23T08:47:29Z</dc:date>
    </item>
    <item>
      <title>Re: delimeted file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delimeted-file/m-p/343626#M78908</link>
      <description>&lt;P&gt;First of all, provide sample data. Use the macro from &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; to convert (part of) your dataset to a datastep that can be posted here ({i} or "little running man" icon).&lt;/P&gt;
&lt;P&gt;I'm particularly intrigued by the fact that 31/03/2016 is treated by Excel once as a date and once as text, so I suspect there's something special in the data.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2017 09:13:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delimeted-file/m-p/343626#M78908</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-03-23T09:13:30Z</dc:date>
    </item>
    <item>
      <title>Re: delimeted file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delimeted-file/m-p/343642#M78915</link>
      <description>&lt;P&gt;One possibility that would produce such results: &amp;nbsp;DATE is actually a character variable that already contains leading blanks. &amp;nbsp;You can rule that out by adding this line before the PUT statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;date = left(date);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, if DATE is actually numeric, don't do this &amp;nbsp;It won't work, and SAS will complain about numeric to character conversion.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also note, you may get a trailing blank after data values. &amp;nbsp;That's probably not a problem but if it happens you can address it with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;put date +(-1) acctno +(-1) name;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2017 10:29:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delimeted-file/m-p/343642#M78915</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-03-23T10:29:26Z</dc:date>
    </item>
    <item>
      <title>Re: delimeted file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delimeted-file/m-p/343933#M78995</link>
      <description>&lt;P&gt;This is the sample code to generate the files&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;libname&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; a &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'C:\Testing Data\ROP'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; try;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;FORMAT&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; DATE &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;DDMMYY10.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; date &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;DDMMYY10.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;cards&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;13032011&lt;/P&gt;
&lt;P&gt;22112016&lt;/P&gt;
&lt;P&gt;01042015&lt;/P&gt;
&lt;P&gt;04072012&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;DATA&lt;/STRONG&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;_NULL_&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;SET&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; TRY;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;FILE&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;"C:\Testing Data\REPORT DATE..txt"&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;DLM&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'|'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;IF&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; _N_ EQ &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;THEN&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;PUT&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; @&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'DATE|'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;PUT&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; DATE;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;RUN&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;when i open up with Excel, those data that contains 0 in the front, will be right justified and the other data that have two digit will be left justified. This might be the problem when open up the report using Excel, however, is there any solution to synchronize all data to be right justified even if I used Excel to read it? Thanks.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2017 02:30:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delimeted-file/m-p/343933#M78995</guid>
      <dc:creator>Hhh111</dc:creator>
      <dc:date>2017-03-24T02:30:57Z</dc:date>
    </item>
    <item>
      <title>Re: delimeted file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delimeted-file/m-p/344067#M79039</link>
      <description>&lt;P&gt;There is nothing wrong with your SAS code or your text file. Excel is assuming that you specify dates in M/D/Y order instead of D/M/Y order. So when it sees a value larger than 12 in the first position it doesn't think it is a date so it stores the value as a character string instead of as a date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could avoid this by using the YYMMDD10. format in SAS when you generate the text file. &amp;nbsp;Excel cannot then confuse those dates. It will store them as dates and display them using your local convention for displaying dates.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2017 15:00:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delimeted-file/m-p/344067#M79039</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-03-24T15:00:11Z</dc:date>
    </item>
    <item>
      <title>Re: delimeted file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delimeted-file/m-p/344486#M79169</link>
      <description>&lt;P&gt;Thanks for your reply Tom. You are correct because when the value is larger than 12, the position will be left justified. Any values lower or equal to 12 will be right justified. I already assign format DDMMYY10. to the date before output to textfile, but the problem still occurs. However, in dataset, the date field is already stored as date format, so Excel shouldnt confuse with the format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any other solution?&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2017 01:33:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delimeted-file/m-p/344486#M79169</guid>
      <dc:creator>Hhh111</dc:creator>
      <dc:date>2017-03-27T01:33:00Z</dc:date>
    </item>
    <item>
      <title>Re: delimeted file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delimeted-file/m-p/344530#M79177</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45239"&gt;@Hhh111&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for your reply Tom. You are correct because when the value is larger than 12, the position will be left justified. Any values lower or equal to 12 will be right justified. I already assign format DDMMYY10. to the date before output to textfile, but the problem still occurs. However, in dataset, the date field is already stored as date format, so Excel shouldnt confuse with the format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any other solution?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Read &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;'s post again.&lt;/P&gt;
&lt;P&gt;DDMMYY10. != YYMMDD10.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2017 07:45:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delimeted-file/m-p/344530#M79177</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-03-27T07:45:53Z</dc:date>
    </item>
    <item>
      <title>Re: delimeted file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delimeted-file/m-p/344531#M79178</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45239"&gt;@Hhh111&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;You could use a date format which Excel understand but which doesn't have the mmdd vs. ddmm issue. Using your code I've used format DATE9. and things worked just fine for me.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data try;
  FORMAT DATE date9.;
  input date DDMMYY10.;
  cards;
13032011
22112016
01042015
04072012
run;

DATA _NULL_;
  SET TRY;
  FILE "C:\temp\REPORT DATE.txt" DLM='|';
  IF _N_ EQ 1 THEN
    PUT @1 'DATE|';
  PUT DATE;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Mar 2017 07:47:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delimeted-file/m-p/344531#M79178</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-03-27T07:47:22Z</dc:date>
    </item>
    <item>
      <title>Re: delimeted file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delimeted-file/m-p/344550#M79185</link>
      <description>&lt;P&gt;TQ for your reply Patrick. Appreciate it. Yes, by using DATE9. format, it is readable using date format and not converted into funny thing. Maybe I need to advise my user that DDMMYY10. will not be a suitable solution if they converted the dlm file into excel manually. As for now, I will assume that is the best solution. Thanks again.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2017 09:16:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delimeted-file/m-p/344550#M79185</guid>
      <dc:creator>Hhh111</dc:creator>
      <dc:date>2017-03-27T09:16:06Z</dc:date>
    </item>
    <item>
      <title>Re: delimeted file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delimeted-file/m-p/344552#M79186</link>
      <description>&lt;P&gt;Oh yes....i put it wrongly. Instead of YYMMDD10. I put DDMMYY10. And yes, it looks fine. I just need to explain to user to avoid confusion. Thanks for&amp;nbsp;the reminder. Thanks again &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2017 09:23:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delimeted-file/m-p/344552#M79186</guid>
      <dc:creator>Hhh111</dc:creator>
      <dc:date>2017-03-27T09:23:55Z</dc:date>
    </item>
  </channel>
</rss>

