<?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 extract &amp;quot;AM&amp;quot; or &amp;quot;PM&amp;quot; from a time variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-quot-AM-quot-or-quot-PM-quot-from-a-time-variable/m-p/561497#M157204</link>
    <description>&lt;P&gt;Or an approach with a custom format:&lt;/P&gt;
&lt;PRE&gt;proc format library=work;
picture myampm
low - high ='%p' (datatype=time)
;
run;

data exammple;
 input x :time5.;
 td = put(x,myampm.);
datalines;
00:01
10:15
14:25
23:59
;
run;&lt;/PRE&gt;
&lt;P&gt;Or just use the format as needed with your existing variable.&lt;/P&gt;</description>
    <pubDate>Fri, 24 May 2019 17:51:17 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2019-05-24T17:51:17Z</dc:date>
    <item>
      <title>How to extract "AM" or "PM" from a time variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-quot-AM-quot-or-quot-PM-quot-from-a-time-variable/m-p/561490#M157200</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a time variable that is in the format of timeampm11.&lt;/P&gt;&lt;P&gt;ex:12:48:06 AM&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I extract the "AM" from the time value? I have tried the following code none of them worked:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; if index(timestamp, 'AM') then td = "AM"; 
 if scan(timestamp,3," ") eq "AM" then td = "AM";&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 May 2019 17:33:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-quot-AM-quot-or-quot-PM-quot-from-a-time-variable/m-p/561490#M157200</guid>
      <dc:creator>lydiawawa</dc:creator>
      <dc:date>2019-05-24T17:33:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract "AM" or "PM" from a time variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-quot-AM-quot-or-quot-PM-quot-from-a-time-variable/m-p/561491#M157201</link>
      <description>If you grab the hour using the hour function and check if that's less than 12 or greater than 12 then it will be pretty easy?&lt;BR /&gt;&lt;BR /&gt;if hour(timestamp) &amp;lt;12 then td='AM';&lt;BR /&gt;else if hour(timestamp) &amp;gt;= 12 then td='PM';&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 24 May 2019 17:37:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-quot-AM-quot-or-quot-PM-quot-from-a-time-variable/m-p/561491#M157201</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-05-24T17:37:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract "AM" or "PM" from a time variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-quot-AM-quot-or-quot-PM-quot-from-a-time-variable/m-p/561497#M157204</link>
      <description>&lt;P&gt;Or an approach with a custom format:&lt;/P&gt;
&lt;PRE&gt;proc format library=work;
picture myampm
low - high ='%p' (datatype=time)
;
run;

data exammple;
 input x :time5.;
 td = put(x,myampm.);
datalines;
00:01
10:15
14:25
23:59
;
run;&lt;/PRE&gt;
&lt;P&gt;Or just use the format as needed with your existing variable.&lt;/P&gt;</description>
      <pubDate>Fri, 24 May 2019 17:51:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-quot-AM-quot-or-quot-PM-quot-from-a-time-variable/m-p/561497#M157204</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-05-24T17:51:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract "AM" or "PM" from a time variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-quot-AM-quot-or-quot-PM-quot-from-a-time-variable/m-p/561556#M157231</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if index(vvalue(timestamp), 'AM') then td = "AM";&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 25 May 2019 11:34:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-quot-AM-quot-or-quot-PM-quot-from-a-time-variable/m-p/561556#M157231</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-05-25T11:34:55Z</dc:date>
    </item>
  </channel>
</rss>

