<?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: Input 1 Variable with 2 data format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Input-1-Variable-with-2-data-format/m-p/228937#M41373</link>
    <description>&lt;P&gt;SAS has an informat ANYDTDTE that will read many different standard date formats.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you're writing the code it would be a good idea to specify the display format that you prefer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;informat thisdate anydtdte.;&lt;/P&gt;
&lt;P&gt;format thisdate mmddyy10.;&lt;/P&gt;
&lt;P&gt;as one example.&lt;/P&gt;</description>
    <pubDate>Wed, 07 Oct 2015 17:14:49 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2015-10-07T17:14:49Z</dc:date>
    <item>
      <title>Input 1 Variable with 2 data format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-1-Variable-with-2-data-format/m-p/228934#M41371</link>
      <description>&lt;P&gt;I am new for SAS. Now, I am learning to read and merge the data sets together.&lt;/P&gt;&lt;P&gt;I have a csv dataset&amp;nbsp;to input and I use the "infile" in my data step&lt;/P&gt;&lt;P&gt;In this file the "date" Variable have 2 data format: date7 and ddmmyy10&lt;/P&gt;&lt;P&gt;What method shall I use to input it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Oct 2015 16:54:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-1-Variable-with-2-data-format/m-p/228934#M41371</guid>
      <dc:creator>transmitToLarry</dc:creator>
      <dc:date>2015-10-07T16:54:25Z</dc:date>
    </item>
    <item>
      <title>Re: Input 1 Variable with 2 data format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-1-Variable-with-2-data-format/m-p/228937#M41373</link>
      <description>&lt;P&gt;SAS has an informat ANYDTDTE that will read many different standard date formats.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you're writing the code it would be a good idea to specify the display format that you prefer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;informat thisdate anydtdte.;&lt;/P&gt;
&lt;P&gt;format thisdate mmddyy10.;&lt;/P&gt;
&lt;P&gt;as one example.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Oct 2015 17:14:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-1-Variable-with-2-data-format/m-p/228937#M41373</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-10-07T17:14:49Z</dc:date>
    </item>
    <item>
      <title>Re: Input 1 Variable with 2 data format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-1-Variable-with-2-data-format/m-p/228938#M41374</link>
      <description>&lt;P&gt;You will have to read in the date variable as a character variable and then convert it to a SAS date. Use a function that will show you what format the character date is in so you use the appropriate informat when converting it to a SAS date. I chose the compress and length functions:&lt;/P&gt;
&lt;P&gt;data test;&lt;BR /&gt;input chardate $10.;&lt;BR /&gt;if length(compress(chardate,,'a')) ne length(chardate) then date=input(chardate,date7.);&lt;BR /&gt;else date=input(chardate,ddmmyy10.);&lt;BR /&gt;format date mmddyy10.;&lt;BR /&gt;cards;&lt;BR /&gt;01sep15&lt;BR /&gt;01092015&lt;BR /&gt;;;;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Oct 2015 17:16:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-1-Variable-with-2-data-format/m-p/228938#M41374</guid>
      <dc:creator>michelle_delaurentis_sas_com</dc:creator>
      <dc:date>2015-10-07T17:16:30Z</dc:date>
    </item>
    <item>
      <title>Re: Input 1 Variable with 2 data format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-1-Variable-with-2-data-format/m-p/228939#M41375</link>
      <description>&lt;P&gt;I dont think that informat will work here:&lt;/P&gt;
&lt;P&gt;data test;&lt;BR /&gt;input date anydtdte.;&lt;BR /&gt;format date mmddyy10.;&lt;BR /&gt;cards;&lt;BR /&gt;01sep15&lt;BR /&gt;01092015&lt;BR /&gt;;;;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;test shows two different dates.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Oct 2015 17:20:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-1-Variable-with-2-data-format/m-p/228939#M41375</guid>
      <dc:creator>michelle_delaurentis_sas_com</dc:creator>
      <dc:date>2015-10-07T17:20:08Z</dc:date>
    </item>
    <item>
      <title>Re: Input 1 Variable with 2 data format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-1-Variable-with-2-data-format/m-p/228950#M41378</link>
      <description>&lt;P&gt;Behavior depends on DATESTYLE option;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options datestyle=DMY;
data test;
input date anydtdte.;
format date mmddyy10.;
cards;
01sep15
01092015
09012015
;;;;
run;


options datestyle=MDY;
data test;
input date anydtdte.;
format date mmddyy10.;
cards;
01sep15
01092015
09012015
;;;;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Oct 2015 17:53:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-1-Variable-with-2-data-format/m-p/228950#M41378</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-10-07T17:53:18Z</dc:date>
    </item>
    <item>
      <title>Re: Input 1 Variable with 2 data format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-1-Variable-with-2-data-format/m-p/228952#M41380</link>
      <description>&lt;P&gt;Important information for using that informat. Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Oct 2015 17:56:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-1-Variable-with-2-data-format/m-p/228952#M41380</guid>
      <dc:creator>michelle_delaurentis_sas_com</dc:creator>
      <dc:date>2015-10-07T17:56:47Z</dc:date>
    </item>
    <item>
      <title>Re: Input 1 Variable with 2 data format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-1-Variable-with-2-data-format/m-p/229151#M41437</link>
      <description>&lt;P&gt;Thanks a lot for answering&lt;/P&gt;&lt;P&gt;I have used the &lt;SPAN&gt;ANYDTDTE informate but it seems it only work on your code but not mine.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;At last I used the method of&amp;nbsp;&lt;SPAN&gt;reading in the date variable as a character variable and converting it into a SAS date.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I modified a little that I used :&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;length&amp;nbsp;chardat &amp;nbsp;$ 10 default=7;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;infile"the csv file";&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;input chardate;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;if length(chardate) ne 10&amp;nbsp;then date=input(chardate,date7.);&lt;BR /&gt;&lt;SPAN&gt;else date=input(chardate,ddmmyy10.);&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2015 15:58:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-1-Variable-with-2-data-format/m-p/229151#M41437</guid>
      <dc:creator>transmitToLarry</dc:creator>
      <dc:date>2015-10-08T15:58:17Z</dc:date>
    </item>
  </channel>
</rss>

