<?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: How to read a column from a text file as character value using proc import in SAS 9.4 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-column-from-a-text-file-as-character-value-using/m-p/247535#M309431</link>
    <description>&lt;P&gt;Hi data_null_,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The&amp;nbsp;mdyampm format changes the value to &amp;nbsp;8/13/2015 12:00 AM from [2015/08/13:12:00:00 AM]. Now, the issue is i am pulling the year and month value from that column and with the new format there is no leading '0' in front of the single date value like '8'. i cannot use substring to pull those values, since the date value is either a single or double digit.&lt;/P&gt;
&lt;P&gt;Is there a format to get the leading zero in the value such as 08/13/2015 12:00 AM instead of 8/13/2015 12:AM&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 02 Feb 2016 17:01:46 GMT</pubDate>
    <dc:creator>SB12</dc:creator>
    <dc:date>2016-02-02T17:01:46Z</dc:date>
    <item>
      <title>How to read a column from a text file as character value using proc import in SAS 9.4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-column-from-a-text-file-as-character-value-using/m-p/247524#M309429</link>
      <description>&lt;P&gt;In SAS 9.2, when i read&amp;nbsp;a text file using proc import to bring as a SAS dataset, one of the column which had date value [2015/08/13:12:00:00 AM] used to be imported as character&amp;nbsp;format and the&amp;nbsp;date value&amp;nbsp;remained the same [2015/08/13:12:00:00 AM].&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now, in SAS 9.4 when i use the same proc import to import the same&amp;nbsp;text file to SAS dataset, the column with the&amp;nbsp;value&amp;nbsp;[2015/08/13:12:00:00 AM] comes in as a date format with the value changed to 13AUG15:00:00:00. We just moved from 9.2 to 9.4.&lt;/P&gt;
&lt;P&gt;Here is the code that was working for me in 9.2.&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;import&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;datafile&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"C:\Desktop\Sample.txt"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;out&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;=test12&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;dbms&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;=dlm&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;replace;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;delimiter&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;','&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;datarow&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;2&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;run&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;I tried to use the option usedate=no but SAS throws me an error.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Feb 2016 16:27:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-column-from-a-text-file-as-character-value-using/m-p/247524#M309429</guid>
      <dc:creator>SB12</dc:creator>
      <dc:date>2016-02-02T16:27:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to read a column from a text file as character value using proc import in SAS 9.4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-column-from-a-text-file-as-character-value-using/m-p/247529#M309430</link>
      <description>&lt;P&gt;It looks like the change with 9.4 is to read the variable as DATE and format it with the default datetime format. &amp;nbsp;You can change the format to display to mdyampm using the format of the same name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want character variable (not useful) you can PUT the data into a new variable using the MDYAMPM. format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could also modify the code generated by PROC IMPORT&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But why. &amp;nbsp;A datetime variable is much more useful that a character string of the same data.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Feb 2016 16:38:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-column-from-a-text-file-as-character-value-using/m-p/247529#M309430</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-02-02T16:38:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to read a column from a text file as character value using proc import in SAS 9.4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-column-from-a-text-file-as-character-value-using/m-p/247535#M309431</link>
      <description>&lt;P&gt;Hi data_null_,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The&amp;nbsp;mdyampm format changes the value to &amp;nbsp;8/13/2015 12:00 AM from [2015/08/13:12:00:00 AM]. Now, the issue is i am pulling the year and month value from that column and with the new format there is no leading '0' in front of the single date value like '8'. i cannot use substring to pull those values, since the date value is either a single or double digit.&lt;/P&gt;
&lt;P&gt;Is there a format to get the leading zero in the value such as 08/13/2015 12:00 AM instead of 8/13/2015 12:AM&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Feb 2016 17:01:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-column-from-a-text-file-as-character-value-using/m-p/247535#M309431</guid>
      <dc:creator>SB12</dc:creator>
      <dc:date>2016-02-02T17:01:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to read a column from a text file as character value using proc import in SAS 9.4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-column-from-a-text-file-as-character-value-using/m-p/247543#M309432</link>
      <description>&lt;P&gt;If you are extracting values from a datetime variable then there are easy ways to do so:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Year = year(datepart(datetimevariablename));&lt;/P&gt;
&lt;P&gt;Month = month(datepart(datetimevariablename));&lt;/P&gt;
&lt;P&gt;Day = day(datepart(datetimevariablename));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not to mention formats that will display the value as desired such as DTDATE, DTMONYY, DTWKDATX, DTYEAR, DTYYQC.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Feb 2016 17:34:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-column-from-a-text-file-as-character-value-using/m-p/247543#M309432</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-02-02T17:34:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to read a column from a text file as character value using proc import in SAS 9.4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-column-from-a-text-file-as-character-value-using/m-p/247558#M309433</link>
      <description>&lt;P&gt;As I mentioned and as&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw﻿&lt;/a&gt;&amp;nbsp;has demonstrated with and example, a DATETIME variable is much easier to work with than a character string.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Feb 2016 18:32:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-column-from-a-text-file-as-character-value-using/m-p/247558#M309433</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-02-02T18:32:54Z</dc:date>
    </item>
  </channel>
</rss>

