<?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 date value from CSV files? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-date-value-from-CSV-files/m-p/20036#M3096</link>
    <description>Thank you. I added : to my codes to read from the two CSV files. They worked!</description>
    <pubDate>Sat, 23 Oct 2010 04:25:19 GMT</pubDate>
    <dc:creator>mnew</dc:creator>
    <dc:date>2010-10-23T04:25:19Z</dc:date>
    <item>
      <title>How to read date value from CSV files?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-date-value-from-CSV-files/m-p/20033#M3093</link>
      <description>Greetings:&lt;BR /&gt;
Trying to figure out an efficient way to read in a very simple CSV file by using Data step (part of my practice for input, infile, informat etc.)... I know how to do this using the import wizard but I simply could not find the way to use a data step for the date field.&lt;BR /&gt;
&lt;BR /&gt;
CSV data: (comma delimited)&lt;BR /&gt;
Abby	1/1/2000&lt;BR /&gt;
Andy	2/1/2001&lt;BR /&gt;
&lt;BR /&gt;
Here is the code I tried first, which did not give an error message but date values were showing up as missing.&lt;BR /&gt;
&lt;BR /&gt;
Filename csvTest 'C:\Documents and Settings\Desktop\SAS_Learning\review\test.csv';&lt;BR /&gt;
&lt;BR /&gt;
data work.testwithoutyear;&lt;BR /&gt;
 	infile csvtest dsd missover;&lt;BR /&gt;
	input first_name $ order_date mmddyy10.;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
The second puzzle: I added a year value as the third variable. (e.g. Abby, 1/1/2000, 2000). &lt;BR /&gt;
Then I ran the code with a slightly modified input statement (input first_name $ order_date mmddyy10. order_year &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt; . This time the SAS dataset has the right order_date but the year showed up as 0 for the example.&lt;BR /&gt;
&lt;BR /&gt;
Any advice?  Do you think I should only use Proc Import to read in CSV and give up the Data step?&lt;BR /&gt;
&lt;BR /&gt;
Thank you!</description>
      <pubDate>Wed, 20 Oct 2010 19:49:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-date-value-from-CSV-files/m-p/20033#M3093</guid>
      <dc:creator>mnew</dc:creator>
      <dc:date>2010-10-20T19:49:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to read date value from CSV files?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-date-value-from-CSV-files/m-p/20034#M3094</link>
      <description>Hello Mnew,&lt;BR /&gt;
&lt;BR /&gt;
I made some experimenting and found that this modification of your code and csv-file works.&lt;BR /&gt;
&lt;BR /&gt;
a) code (delimiter and format )&lt;BR /&gt;
&lt;BR /&gt;
data work.testwithoutyear;&lt;BR /&gt;
infile csvtest delimiter=',' missover;&lt;BR /&gt;
input first_name $ order_date mmddyy10. year;&lt;BR /&gt;
format order_date mmddyy10.;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Data: (2 blanks before dates because format requires 10 symbols)&lt;BR /&gt;
&lt;BR /&gt;
Abby,  1/1/2000,2000&lt;BR /&gt;
Andy,  2/1/2001,2001&lt;BR /&gt;
&lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
      <pubDate>Wed, 20 Oct 2010 20:56:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-date-value-from-CSV-files/m-p/20034#M3094</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2010-10-20T20:56:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to read date value from CSV files?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-date-value-from-CSV-files/m-p/20035#M3095</link>
      <description>Hi:&lt;BR /&gt;
  If you use the colon modifier for the INPUT statement, you will be instructing SAS to read the data using a specific INFORMAT (in this case MMDDYY10.). For more about the colon modifier for INPUT, read the documentation topic entitled: "Modified List Input" which shows examples of the colon format modifier:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a003209907.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a003209907.htm&lt;/A&gt;&lt;BR /&gt;
         &lt;BR /&gt;
cynthia&lt;BR /&gt;
[pre]&lt;BR /&gt;
data work.testdata;&lt;BR /&gt;
  infile datalines delimiter=',' ;&lt;BR /&gt;
  input first_name $ order_date : mmddyy10. year;&lt;BR /&gt;
  format order_date mmddyy10.;&lt;BR /&gt;
return;&lt;BR /&gt;
datalines;&lt;BR /&gt;
Abby,1/1/2000,2000&lt;BR /&gt;
Andy,2/1/2001,2001&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
     &lt;BR /&gt;
ods listing;    &lt;BR /&gt;
proc print data=testdata;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Thu, 21 Oct 2010 01:10:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-date-value-from-CSV-files/m-p/20035#M3095</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-10-21T01:10:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to read date value from CSV files?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-date-value-from-CSV-files/m-p/20036#M3096</link>
      <description>Thank you. I added : to my codes to read from the two CSV files. They worked!</description>
      <pubDate>Sat, 23 Oct 2010 04:25:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-date-value-from-CSV-files/m-p/20036#M3096</guid>
      <dc:creator>mnew</dc:creator>
      <dc:date>2010-10-23T04:25:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to read date value from CSV files?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-date-value-from-CSV-files/m-p/20037#M3097</link>
      <description>Thank you. Tested your solution. It worked fine. Agree with you that it's the informat!</description>
      <pubDate>Sat, 23 Oct 2010 04:29:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-date-value-from-CSV-files/m-p/20037#M3097</guid>
      <dc:creator>mnew</dc:creator>
      <dc:date>2010-10-23T04:29:51Z</dc:date>
    </item>
  </channel>
</rss>

