<?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 import .csv file with date correctly in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-import-csv-file-with-date-correctly/m-p/740458#M29065</link>
    <description>data Lab_test;&lt;BR /&gt;  infile "&amp;amp;path\Lab_test.csv" dsd truncover firstobs=2;&lt;BR /&gt;  length Test_ID $10 Test_date 8 Test 8 Test_unit $10 Test_ref $20 ;&lt;BR /&gt;  informat test_date YYMMDD.;&lt;BR /&gt;  format test_date yymmdd10.;&lt;BR /&gt;  input test_id -- test_ref;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;So, I can import this way?</description>
    <pubDate>Tue, 11 May 2021 13:17:27 GMT</pubDate>
    <dc:creator>mantubiradar19</dc:creator>
    <dc:date>2021-05-11T13:17:27Z</dc:date>
    <item>
      <title>How to import .csv file with date correctly</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-import-csv-file-with-date-correctly/m-p/740441#M29059</link>
      <description>&lt;P&gt;Hello everyone, I'm trying to import the .csv file containing data into SAS. However, the date column is converted to char and format as&amp;nbsp;$12.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please suggest to me a way import this data correctly into SAS. Here are the first few observations from the.csv file:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Test_ID	Test_date	Test	Test_unit	Test_ref
M00000001	27-05-19	2.92	g/dL	3.8-5.3
M00000001	03-06-19	3.08	g/dL	3.8-5.3
M00000001	05-06-19	3.24	g/dL	3.8-5.3
M00000001	10-06-19	3.51	g/dL	3.8-5.3
M00000001	18-06-19	3.76	g/dL	3.8-5.3
M00000001	13-03-20	3.06	g/dL	3.8-5.3
M00000001	23-03-20	3.4	g/dL	3.8-5.3
M00000001	03-04-20	3.72	g/dL	3.8-5.3
M00000002	11-01-17	3.39	g/dL	3.8-5.3
M00000002	18-01-17	3.53	g/dL	3.8-5.3
M00000003	24-11-16	4.18	g/dL	3.8-5.3
M00000003	07-06-18	4.44	g/dL	3.8-5.3
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And here is the import code I have used:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let path=E:\Lab_tests;
options validvarname=v7;

proc import datafile="&amp;amp;path\Lab_test.csv"
out=Lab_test
dbms=csv REPLACE;
guessingrows=max;
run;quit; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thanks in advance&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 May 2021 12:22:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-import-csv-file-with-date-correctly/m-p/740441#M29059</guid>
      <dc:creator>mantubiradar19</dc:creator>
      <dc:date>2021-05-11T12:22:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to import .csv file with date correctly</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-import-csv-file-with-date-correctly/m-p/740446#M29062</link>
      <description>&lt;P&gt;If your CSV really looks like what you posted then you should get only one variable because there are no commas there.&amp;nbsp; Are you sure you did not open the file in Excel and copy and paste some of the cells from the Excel spreadsheet that Excel created from the CSV file?&amp;nbsp; Open the CSV file in a text editor. Or just type it to the terminal window. Or view it with the SAS editor.&amp;nbsp; Or a simple data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the file only has 5 variables then skip the PROC IMPORT and just write your own data step to read it.&lt;/P&gt;
&lt;P&gt;If you are not sure what style the date values have try using ANYDTDTE informat.&amp;nbsp; But if you really have 2 digit years you might have trouble. And if your know that the data is in M-D-Y or D-M-Y order then MMDDYY or DDMMYY informat instead, otherwise depending on your language settings ANYDTDTE might convert December tenth into twelfth of October.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Lab_test;
  infile "&amp;amp;path\Lab_test.csv" dsd truncover firstobs=2;
  length Test_ID $10 Test_date 8 Test 8 Test_unit $10 Test_ref $20 ;
  informat test_date anydtdte.;
  format test_date yymmdd10.;
  input test_id -- test_ref;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 May 2021 12:55:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-import-csv-file-with-date-correctly/m-p/740446#M29062</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-11T12:55:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to import .csv file with date correctly</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-import-csv-file-with-date-correctly/m-p/740454#M29063</link>
      <description>&lt;P&gt;Sorry, earlier I opened the .csv file with excel to view it. Here are the observations as seen using text editor:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;"Test_ID","Test_date","Test","Test_unit","test_ref"
"M00000001","2019/05/27","2.92","g/dL","3.8-5.3"
"M00000001","2019/06/03","3.08","g/dL","3.8-5.3"
"M00000001","2019/06/05","3.24","g/dL","3.8-5.3"
"M00000001","2019/06/10","3.51","g/dL","3.8-5.3"
"M00000001","2019/06/18","3.76","g/dL","3.8-5.3"
"M00000001","2020/03/13","3.06","g/dL","3.8-5.3"
"M00000001","2020/03/23","3.40","g/dL","3.8-5.3"
"M00000001","2020/04/03","3.72","g/dL","3.8-5.3"
"M00000002","2017/01/11","3.39","g/dL","3.8-5.3"
"M00000002","2017/01/18","3.53","g/dL","3.8-5.3"
"M00000003","2016/11/24","4.18","g/dL","3.8-5.3"
"M00000003","2018/06/07","4.44","g/dL","3.8-5.3"
"M00000004","2018/01/15","3.59","g/dL","3.8-5.3"
"M00000004","2018/01/21","3.61","g/dL","3.8-5.3"
&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The dates are in&amp;nbsp;&lt;SPAN&gt;D-M-Y&amp;nbsp;order.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 May 2021 13:10:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-import-csv-file-with-date-correctly/m-p/740454#M29063</guid>
      <dc:creator>mantubiradar19</dc:creator>
      <dc:date>2021-05-11T13:10:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to import .csv file with date correctly</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-import-csv-file-with-date-correctly/m-p/740455#M29064</link>
      <description>&lt;P&gt;Actually they are in YMD order.&amp;nbsp; PROC IMPORT should handle that fine.&lt;/P&gt;
&lt;P&gt;But PROC IMPORT has a "feature" that if every cell is quoted it thinks that means you want to define it as character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The data step I posted before should work using ANYDTDTE informat.&amp;nbsp; You might want to change to YYMMDD informat instead.&amp;nbsp; That would cause SAS to report date strings that are not in Y-M-D order as errors.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 May 2021 13:14:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-import-csv-file-with-date-correctly/m-p/740455#M29064</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-11T13:14:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to import .csv file with date correctly</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-import-csv-file-with-date-correctly/m-p/740458#M29065</link>
      <description>data Lab_test;&lt;BR /&gt;  infile "&amp;amp;path\Lab_test.csv" dsd truncover firstobs=2;&lt;BR /&gt;  length Test_ID $10 Test_date 8 Test 8 Test_unit $10 Test_ref $20 ;&lt;BR /&gt;  informat test_date YYMMDD.;&lt;BR /&gt;  format test_date yymmdd10.;&lt;BR /&gt;  input test_id -- test_ref;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;So, I can import this way?</description>
      <pubDate>Tue, 11 May 2021 13:17:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-import-csv-file-with-date-correctly/m-p/740458#M29065</guid>
      <dc:creator>mantubiradar19</dc:creator>
      <dc:date>2021-05-11T13:17:27Z</dc:date>
    </item>
  </channel>
</rss>

