<?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: Converting CSV character dates to SAS dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Converting-CSV-character-dates-to-SAS-dates/m-p/435777#M282079</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/153898"&gt;@ogarduno&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I have the following question to answer:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The main outcome of interest is whether the defendant was arrested again prior to his/her disposition (trial or court appearance) date. create a variable called 're_arrest' that equals one if the defendant was arrested prior to trial and zero otherwise e.g. imagine person 1 was arrested three times&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;caseid personid arrest_date&amp;nbsp; &amp;nbsp; dispos_date&amp;nbsp; re_arrest&lt;/P&gt;
&lt;P&gt;123&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2012-01-01&amp;nbsp; &amp;nbsp; &amp;nbsp;2012-04-05&amp;nbsp; &amp;nbsp; 0&lt;/P&gt;
&lt;P&gt;1344&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2012-06-05&amp;nbsp; &amp;nbsp; &amp;nbsp;2012-09-13&amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;
&lt;P&gt;1451&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2012-07-09&amp;nbsp; &amp;nbsp; &amp;nbsp;2012-11-21&amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The dates a character value so i want to convert them into a sas date. I was thinking of approaching this by creating an if and then statement so if the date is in between the disposition date it would create 1 in the new variable. However, I'm having trouble inputting the csv file into sas and converting it into a sas date. Can anyone help me and if my approach is feasible?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Show 1) the code you used to create the SAS data set from the CSV and 2) a copy&amp;nbsp;few lines of the data AS TEXT (do not use Excel use something like Notepad or even the SAS editor), paste a few rows of the data into a code box here opened using the forum {I}&lt;/P&gt;
&lt;P&gt;icon. Change any sensitive data before pasting it here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The dates should read just fine with proc import unless 1) they have quotes around them in the CSV such as&lt;/P&gt;
&lt;P&gt;123,1,'2012-01-01','2012-04-05',0&lt;/P&gt;
&lt;P&gt;or the dates come in different formats or possibly the first few rows are missing the dates. Proc Import guesses variable types and formats from a small number of rows and changes or missing values make those "guesses" less useful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 09 Feb 2018 18:26:24 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2018-02-09T18:26:24Z</dc:date>
    <item>
      <title>Converting CSV character dates to SAS dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-CSV-character-dates-to-SAS-dates/m-p/435746#M282075</link>
      <description>&lt;P&gt;I have the following question to answer:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The main outcome of interest is whether the defendant was arrested again prior to his/her disposition (trial or court appearance) date. create a variable called 're_arrest' that equals one if the defendant was arrested prior to trial and zero otherwise e.g. imagine person 1 was arrested three times&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;caseid personid arrest_date&amp;nbsp; &amp;nbsp; dispos_date&amp;nbsp; re_arrest&lt;/P&gt;&lt;P&gt;123&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2012-01-01&amp;nbsp; &amp;nbsp; &amp;nbsp;2012-04-05&amp;nbsp; &amp;nbsp; 0&lt;/P&gt;&lt;P&gt;1344&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2012-06-05&amp;nbsp; &amp;nbsp; &amp;nbsp;2012-09-13&amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;1451&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2012-07-09&amp;nbsp; &amp;nbsp; &amp;nbsp;2012-11-21&amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The dates a character value so i want to convert them into a sas date. I was thinking of approaching this by creating an if and then statement so if the date is in between the disposition date it would create 1 in the new variable. However, I'm having trouble inputting the csv file into sas and converting it into a sas date. Can anyone help me and if my approach is feasible?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2018 17:59:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-CSV-character-dates-to-SAS-dates/m-p/435746#M282075</guid>
      <dc:creator>ogarduno</dc:creator>
      <dc:date>2018-02-09T17:59:00Z</dc:date>
    </item>
    <item>
      <title>Re: Converting CSV character dates to SAS dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-CSV-character-dates-to-SAS-dates/m-p/435756#M282076</link>
      <description>&lt;P&gt;Can I ask how you're reading in the CSV file?&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2018 18:08:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-CSV-character-dates-to-SAS-dates/m-p/435756#M282076</guid>
      <dc:creator>antonbcristina</dc:creator>
      <dc:date>2018-02-09T18:08:24Z</dc:date>
    </item>
    <item>
      <title>Re: Converting CSV character dates to SAS dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-CSV-character-dates-to-SAS-dates/m-p/435760#M282077</link>
      <description>I'm tired using filename infile procedure and proc import but none to my&lt;BR /&gt;luck&lt;BR /&gt;</description>
      <pubDate>Fri, 09 Feb 2018 18:13:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-CSV-character-dates-to-SAS-dates/m-p/435760#M282077</guid>
      <dc:creator>ogarduno</dc:creator>
      <dc:date>2018-02-09T18:13:51Z</dc:date>
    </item>
    <item>
      <title>Re: Converting CSV character dates to SAS dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-CSV-character-dates-to-SAS-dates/m-p/435767#M282078</link>
      <description>&lt;P&gt;Can you post your code and log? It will help to figure out what is going on.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2018 18:18:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-CSV-character-dates-to-SAS-dates/m-p/435767#M282078</guid>
      <dc:creator>antonbcristina</dc:creator>
      <dc:date>2018-02-09T18:18:40Z</dc:date>
    </item>
    <item>
      <title>Re: Converting CSV character dates to SAS dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-CSV-character-dates-to-SAS-dates/m-p/435777#M282079</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/153898"&gt;@ogarduno&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I have the following question to answer:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The main outcome of interest is whether the defendant was arrested again prior to his/her disposition (trial or court appearance) date. create a variable called 're_arrest' that equals one if the defendant was arrested prior to trial and zero otherwise e.g. imagine person 1 was arrested three times&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;caseid personid arrest_date&amp;nbsp; &amp;nbsp; dispos_date&amp;nbsp; re_arrest&lt;/P&gt;
&lt;P&gt;123&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2012-01-01&amp;nbsp; &amp;nbsp; &amp;nbsp;2012-04-05&amp;nbsp; &amp;nbsp; 0&lt;/P&gt;
&lt;P&gt;1344&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2012-06-05&amp;nbsp; &amp;nbsp; &amp;nbsp;2012-09-13&amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;
&lt;P&gt;1451&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2012-07-09&amp;nbsp; &amp;nbsp; &amp;nbsp;2012-11-21&amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The dates a character value so i want to convert them into a sas date. I was thinking of approaching this by creating an if and then statement so if the date is in between the disposition date it would create 1 in the new variable. However, I'm having trouble inputting the csv file into sas and converting it into a sas date. Can anyone help me and if my approach is feasible?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Show 1) the code you used to create the SAS data set from the CSV and 2) a copy&amp;nbsp;few lines of the data AS TEXT (do not use Excel use something like Notepad or even the SAS editor), paste a few rows of the data into a code box here opened using the forum {I}&lt;/P&gt;
&lt;P&gt;icon. Change any sensitive data before pasting it here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The dates should read just fine with proc import unless 1) they have quotes around them in the CSV such as&lt;/P&gt;
&lt;P&gt;123,1,'2012-01-01','2012-04-05',0&lt;/P&gt;
&lt;P&gt;or the dates come in different formats or possibly the first few rows are missing the dates. Proc Import guesses variable types and formats from a small number of rows and changes or missing values make those "guesses" less useful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2018 18:26:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-CSV-character-dates-to-SAS-dates/m-p/435777#M282079</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-02-09T18:26:24Z</dc:date>
    </item>
    <item>
      <title>Re: Converting CSV character dates to SAS dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-CSV-character-dates-to-SAS-dates/m-p/435778#M282080</link>
      <description>&lt;P&gt;filename inp1 'c:desktop\case.csv';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data case;&lt;/P&gt;&lt;P&gt;infile inp1;&lt;/P&gt;&lt;P&gt;informat arrest_date mmddyy10. dispos_date mmddyy10.;&lt;/P&gt;&lt;P&gt;input case_id arrest_date dispos_date;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc print;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2018 18:26:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-CSV-character-dates-to-SAS-dates/m-p/435778#M282080</guid>
      <dc:creator>ogarduno</dc:creator>
      <dc:date>2018-02-09T18:26:38Z</dc:date>
    </item>
    <item>
      <title>Re: Converting CSV character dates to SAS dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-CSV-character-dates-to-SAS-dates/m-p/435783#M282081</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/153898"&gt;@ogarduno&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;filename inp1 'c:desktop\case.csv';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data case;&lt;/P&gt;
&lt;P&gt;infile inp1;&lt;/P&gt;
&lt;P&gt;informat arrest_date &lt;FONT color="#ff0000"&gt;YYMMDD&lt;/FONT&gt;10. dispos_date &lt;FONT color="#ff0000"&gt;YYMMDD&lt;/FONT&gt;10.;&lt;/P&gt;
&lt;P&gt;input case_id arrest_date dispos_date;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc print;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Your dates obviously start with Years not months. You should have gotten many "invalid data" messages in the log.&lt;/P&gt;
&lt;P&gt;It usually helps to add a FORMAT statement to display the values when you read them as well.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2018 18:35:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-CSV-character-dates-to-SAS-dates/m-p/435783#M282081</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-02-09T18:35:48Z</dc:date>
    </item>
  </channel>
</rss>

