<?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: SAS DATETIME in AM/PM Conversion in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-DATETIME-in-AM-PM-Conversion/m-p/337921#M272560</link>
    <description>Worked fine in PC SAS, however, when I am trying to run my sas code in unix environment, I am getting following errros -&lt;BR /&gt;&lt;BR /&gt;The format $YYMMDD was not found or could not be loaded.&lt;BR /&gt;&lt;BR /&gt;The format $TOD was not found or could not be loaded.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Is there a reason for why it would error out?</description>
    <pubDate>Fri, 03 Mar 2017 17:34:20 GMT</pubDate>
    <dc:creator>Arpit_Agarwal</dc:creator>
    <dc:date>2017-03-03T17:34:20Z</dc:date>
    <item>
      <title>SAS DATETIME in AM/PM Conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-DATETIME-in-AM-PM-Conversion/m-p/337859#M272557</link>
      <description>&lt;P&gt;Hello experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am struggling to convert the sas datetime values&amp;nbsp;with AM/PM at the end to something like yyyymmddhhmmssffffff.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let's say -&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Input value :&lt;/P&gt;&lt;P&gt;2/8/2017 8:10:41 AM&lt;/P&gt;&lt;P&gt;2/24/2017 11:38:15&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My expected value :&lt;/P&gt;&lt;P&gt;20170208081041000000&lt;/P&gt;&lt;P&gt;20170224113815000000&amp;nbsp; (ffffff can be&amp;nbsp;put as&amp;nbsp;000000 for the last 6 digits&amp;nbsp;at the end for all records).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I do that? Please advise.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2017 15:21:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-DATETIME-in-AM-PM-Conversion/m-p/337859#M272557</guid>
      <dc:creator>Arpit_Agarwal</dc:creator>
      <dc:date>2017-03-03T15:21:14Z</dc:date>
    </item>
    <item>
      <title>Re: SAS DATETIME in AM/PM Conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-DATETIME-in-AM-PM-Conversion/m-p/337869#M272558</link>
      <description>&lt;P&gt;Such values can be read with the anydtdtm. format. Take special care of the missing AM/PM, as in your second example; within an AM/PM context, that value is ambiguous.&lt;/P&gt;
&lt;P&gt;AFAIK, there is no SAS datetime format that creates your output in one step.&lt;/P&gt;
&lt;P&gt;You could try to roll your own picture format (described&amp;nbsp;&lt;A href="http://support.sas.com/documentation/cdl/en/proc/69850/HTML/default/viewer.htm#p0n990vq8gxca6n1vnsracr6jp2c.htm" target="_blank"&gt;here&lt;/A&gt;), or you could extract date and time using the datepart() and timepart() functions, and use formats without separators (eg yymmddn8.) to build your string.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2017 15:41:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-DATETIME-in-AM-PM-Conversion/m-p/337869#M272558</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-03-03T15:41:16Z</dc:date>
    </item>
    <item>
      <title>Re: SAS DATETIME in AM/PM Conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-DATETIME-in-AM-PM-Conversion/m-p/337870#M272559</link>
      <description>&lt;P&gt;Couple of questions, how do you know 11:24 is pm, is it the abscence of AM? &amp;nbsp;Also, the output format is not like any date time I have ever seen, are you really sure you want to do that?&lt;/P&gt;
&lt;P&gt;Also in the future post test data in the form of a datastep, I am going to assume that field is character:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data want;
  length thedt want $200;
  infile datalines dlm="¬";
  input thedt $;
  dpart=input(scan(thedt,1," "),mmddyy10.);
  tpart=input(scan(thedt,2," "),time8.);
  if scan(thedt,3," ") ne "AM" then tpart=tpart+"12:00"t;
  want=cats(compress(tranwrd(put(dpart,yymmdd10.),"-","")),compress(tranwrd(put(tpart,tod8.),":","")));
  format dpart date9. tpart time8.;
datalines;
2/8/2017 8:10:41 AM
2/24/2017 11:38:15
;
run;&lt;/PRE&gt;
&lt;P&gt;Note the above is abit verbose to show workings. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2017 15:42:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-DATETIME-in-AM-PM-Conversion/m-p/337870#M272559</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-03-03T15:42:17Z</dc:date>
    </item>
    <item>
      <title>Re: SAS DATETIME in AM/PM Conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-DATETIME-in-AM-PM-Conversion/m-p/337921#M272560</link>
      <description>Worked fine in PC SAS, however, when I am trying to run my sas code in unix environment, I am getting following errros -&lt;BR /&gt;&lt;BR /&gt;The format $YYMMDD was not found or could not be loaded.&lt;BR /&gt;&lt;BR /&gt;The format $TOD was not found or could not be loaded.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Is there a reason for why it would error out?</description>
      <pubDate>Fri, 03 Mar 2017 17:34:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-DATETIME-in-AM-PM-Conversion/m-p/337921#M272560</guid>
      <dc:creator>Arpit_Agarwal</dc:creator>
      <dc:date>2017-03-03T17:34:20Z</dc:date>
    </item>
    <item>
      <title>Re: SAS DATETIME in AM/PM Conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-DATETIME-in-AM-PM-Conversion/m-p/337932#M272561</link>
      <description>&lt;P&gt;Date and datetime formats are numeric formats, therefore omit the dollar sign.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2017 17:56:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-DATETIME-in-AM-PM-Conversion/m-p/337932#M272561</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-03-03T17:56:31Z</dc:date>
    </item>
    <item>
      <title>Re: SAS DATETIME in AM/PM Conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-DATETIME-in-AM-PM-Conversion/m-p/337933#M272562</link>
      <description>&lt;P&gt;Please post the code with error messages from the log. Use the {i} menu icon in the forum to open a code box that preserves the format of the log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The message $yymmdd not found usually results from attempting to apply a date format, which uses numeric values, to a character value. We would have to see the entire code you used to know exactly what is triggering this.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2017 17:58:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-DATETIME-in-AM-PM-Conversion/m-p/337933#M272562</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-03-03T17:58:40Z</dc:date>
    </item>
    <item>
      <title>Re: SAS DATETIME in AM/PM Conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-DATETIME-in-AM-PM-Conversion/m-p/338384#M272563</link>
      <description>&lt;P&gt;It is one of two things, either your program is not the same between the two systems, or your data is not the same between the two systems. &amp;nbsp;As I can't see either data or programs at either stage I don't see how I could say?&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2017 09:32:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-DATETIME-in-AM-PM-Conversion/m-p/338384#M272563</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-03-06T09:32:00Z</dc:date>
    </item>
    <item>
      <title>Re: SAS DATETIME in AM/PM Conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-DATETIME-in-AM-PM-Conversion/m-p/339321#M272564</link>
      <description>&lt;P&gt;Thank you RW9.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is how it worked for me -&lt;/P&gt;&lt;P&gt;a) Let's assume - original datasset is A&lt;/P&gt;&lt;P&gt;b) I had to take out the date field and the KEY in a new dataset, say B.&lt;/P&gt;&lt;P&gt;c) I applied above logic on B to create C with the new date field having values in the format I was interested in.&lt;/P&gt;&lt;P&gt;d) Merged A and C, on the basis of the KEY.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;..and I do not know how to explain why it would not work on the original dataset only.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Appreciate your help!&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2017 17:01:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-DATETIME-in-AM-PM-Conversion/m-p/339321#M272564</guid>
      <dc:creator>Arpit_Agarwal</dc:creator>
      <dc:date>2017-03-08T17:01:50Z</dc:date>
    </item>
    <item>
      <title>Re: SAS DATETIME in AM/PM Conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-DATETIME-in-AM-PM-Conversion/m-p/339323#M272565</link>
      <description>&lt;P&gt;Thank you everyone, RW9's solution worked for me. But a huge thanks for each one who responded! Much thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2017 17:03:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-DATETIME-in-AM-PM-Conversion/m-p/339323#M272565</guid>
      <dc:creator>Arpit_Agarwal</dc:creator>
      <dc:date>2017-03-08T17:03:20Z</dc:date>
    </item>
  </channel>
</rss>

