<?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: Import CSV file with date and time in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Import-CSV-file-with-date-and-time/m-p/401346#M66763</link>
    <description>&lt;P&gt;Use a manually written data step, and convert to a SAS datetime value:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
infile cards dlm=',';
input Country :$20. Name $ Age Sex :$1. Registration_string :$20. Rank SeqNo $;
reg_date = input(scan(Registration_string,1,' '),ddmmyy10.);
reg_time = input(scan(Registration_string,2,' '),time5.);
registration = reg_date * 86400 + reg_time;
format registration datetime19.;
drop Registration_string reg_date reg_time;
cards;
India,AA12,21,M,28/06/2017 14:09,1,A-001
Bhutan,AA123,21,F,28/06/2017 14:09,2,A-002
Srilanka,AA234,21,M,19/09/2017 23:59,3,A-003
US,AA345,21,F,26/09/2017 04:14,4,A-004
UK,AA456,21,M,28/09/2017 03:20,5,A-005
USSR,AA567,21,F,19/09/2017 23:59,6,A-006
China,AA678,21,M,21/09/2017 03:23,7,A-007
Japan,AA789,21,F,30/06/2017 16:34,8,A-008
SK,AA900,21,M,30/06/2017 16:34,9,A-009
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 05 Oct 2017 14:12:21 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2017-10-05T14:12:21Z</dc:date>
    <item>
      <title>Import CSV file with date and time</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Import-CSV-file-with-date-and-time/m-p/401336#M66761</link>
      <description>&lt;P&gt;Hello Everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to import the CSV file into SAS dataset and save it in a library. The excel file contain around 5 lakhs records.&lt;/P&gt;
&lt;P&gt;I wrote the below code but how to capture the time, I have no idea.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Libname Store "/tempo/CSV/project/";

proc import datafile="/tempo/CSV/project/information.csv"
     out=Mydata
     dbms=csv
     replace;
     getnames=yes;
run;

data Store.D_01SEP2017;
set Mydata;
run;&lt;/PRE&gt;
&lt;P&gt;Also If I want to add one sample record with current date, can I use&amp;nbsp;datetime22.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2017 13:51:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Import-CSV-file-with-date-and-time/m-p/401336#M66761</guid>
      <dc:creator>dash</dc:creator>
      <dc:date>2017-10-05T13:51:44Z</dc:date>
    </item>
    <item>
      <title>Re: Import CSV file with date and time</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Import-CSV-file-with-date-and-time/m-p/401346#M66763</link>
      <description>&lt;P&gt;Use a manually written data step, and convert to a SAS datetime value:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
infile cards dlm=',';
input Country :$20. Name $ Age Sex :$1. Registration_string :$20. Rank SeqNo $;
reg_date = input(scan(Registration_string,1,' '),ddmmyy10.);
reg_time = input(scan(Registration_string,2,' '),time5.);
registration = reg_date * 86400 + reg_time;
format registration datetime19.;
drop Registration_string reg_date reg_time;
cards;
India,AA12,21,M,28/06/2017 14:09,1,A-001
Bhutan,AA123,21,F,28/06/2017 14:09,2,A-002
Srilanka,AA234,21,M,19/09/2017 23:59,3,A-003
US,AA345,21,F,26/09/2017 04:14,4,A-004
UK,AA456,21,M,28/09/2017 03:20,5,A-005
USSR,AA567,21,F,19/09/2017 23:59,6,A-006
China,AA678,21,M,21/09/2017 03:23,7,A-007
Japan,AA789,21,F,30/06/2017 16:34,8,A-008
SK,AA900,21,M,30/06/2017 16:34,9,A-009
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Oct 2017 14:12:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Import-CSV-file-with-date-and-time/m-p/401346#M66763</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-05T14:12:21Z</dc:date>
    </item>
    <item>
      <title>Re: Import CSV file with date and time</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Import-CSV-file-with-date-and-time/m-p/401350#M66764</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;SPAN class="login-bold"&gt;&lt;A id="link_8" class="lia-link-navigation lia-page-link lia-user-name-link" href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562" target="_self"&gt;KurtBremser&lt;/A&gt;&amp;nbsp;for your support.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="login-bold"&gt;But my excel file contain more than 5 lakhs records. In that scenario, I think proc import is the suitable procedure.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="login-bold"&gt;It is not possible to write data for all 5 lakhs records&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2017 14:15:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Import-CSV-file-with-date-and-time/m-p/401350#M66764</guid>
      <dc:creator>dash</dc:creator>
      <dc:date>2017-10-05T14:15:58Z</dc:date>
    </item>
    <item>
      <title>Re: Import CSV file with date and time</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Import-CSV-file-with-date-and-time/m-p/401354#M66765</link>
      <description>&lt;P&gt;Firstly, and most importantly, CSV is not Excel!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Secondly your letting SAS guess what your import should look like - i.e. the proc import.&amp;nbsp; If you want data in a specific format then write the code yourself, e.g.:&lt;/P&gt;
&lt;PRE&gt;data want;
  infile "...information.csv" dlm=",";
  length ...;
  informat ...;
  format ...;
  input...;
run;
  &lt;/PRE&gt;
&lt;P&gt;So you specify the length informat format, on how to read in the text data.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2017 14:22:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Import-CSV-file-with-date-and-time/m-p/401354#M66765</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-10-05T14:22:32Z</dc:date>
    </item>
    <item>
      <title>Re: Import CSV file with date and time</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Import-CSV-file-with-date-and-time/m-p/401357#M66766</link>
      <description>&lt;P&gt;In fact, a data step is ALWAYS the better solution, as you have full control over the process (while proc import relies on guesses).&lt;/P&gt;
&lt;P&gt;The number of records does not matter, apart from issues with space in the target library. Again, you have better control over the space needed with a data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW, when importing a csv file, proc import does write a data step on its own and runs that. You can find this data step in the SAS log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;500.000 observations of the structure you gave will need &amp;lt; 50 MB, trivial with SAS. That's not even "small", that's negligibly close to nothing &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2017 14:25:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Import-CSV-file-with-date-and-time/m-p/401357#M66766</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-05T14:25:58Z</dc:date>
    </item>
    <item>
      <title>Re: Import CSV file with date and time</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Import-CSV-file-with-date-and-time/m-p/401358#M66767</link>
      <description>&lt;P&gt;PS I used cards; in the data step only for easier illustration. Drop the cards; section and add your original infile statement to read from the file.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2017 14:27:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Import-CSV-file-with-date-and-time/m-p/401358#M66767</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-05T14:27:26Z</dc:date>
    </item>
    <item>
      <title>Re: Import CSV file with date and time</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Import-CSV-file-with-date-and-time/m-p/401377#M66768</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19789"&gt;@dash&lt;/a&gt;&amp;nbsp;you've misunderstood&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can point a data step to a file rather than use CARDS as he did.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In fact, look at your log for the code and add in the components you need.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's more work to download your file and work with it, so a data step example with CARDS is easier to post here.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2017 15:02:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Import-CSV-file-with-date-and-time/m-p/401377#M66768</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-05T15:02:39Z</dc:date>
    </item>
  </channel>
</rss>

