<?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: Why is the time truncating and how do I fix it? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Why-is-the-time-truncating-and-how-do-I-fix-it/m-p/948305#M371076</link>
    <description>&lt;P&gt;Using right input method(list input) and pick up the right format .&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Earthquakes;
infile cards truncover;
input Date : yymmdd12. Time : time14. Magnitude  Latitude  Longitude ;
format Date mmddyy10. Time timeampm18.2 Magnitude f10.2  Latitude  Longitude f12.3;
cards;
2022/01/10 14:54:28.81 0.36 33.512 -116.768  
2022/01/10 15:16:32.60 0.96 33.184 -116.031   
2022/01/10 15:43:09.41 1.09 35.680 -117.535   
2022/01/10 16:33:07.48 0.68 33.588 -116.808 
2022/01/10 17:14:17.90 0.86 36.032 -117.807 
2022/01/10 18:00:07.32 0.61 35.765 -117.580 
2022/01/10 18:50:47.06 0.90 35.586 -117.462   
2022/01/10 18:59:47.00 2.61 35.648 -115.927 
;
run;

proc print data = Earthquakes;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1729476697239.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/101590iC3AFF4B3F46776FD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1729476697239.png" alt="Ksharp_0-1729476697239.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 21 Oct 2024 02:11:50 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2024-10-21T02:11:50Z</dc:date>
    <item>
      <title>Why is the time truncating and how do I fix it?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-is-the-time-truncating-and-how-do-I-fix-it/m-p/948302#M371075</link>
      <description>&lt;P&gt;I have data on earthquakes that look something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Date        Time       Magnitude Latitude  Longitude

2022/01/10 14:54:28.81 0.36 33.512 -116.768  
2022/01/10 15:16:32.60 0.96 33.184 -116.031   
2022/01/10 15:43:09.41 1.09 35.680 -117.535   
2022/01/10 16:33:07.48 0.68 33.588 -116.808 
2022/01/10 17:14:17.90 0.86 36.032 -117.807 
2022/01/10 18:00:07.32 0.61 35.765 -117.580 
2022/01/10 18:50:47.06 0.90 35.586 -117.462   
2022/01/10 18:59:47.00 2.61 35.648 -115.927 &lt;/PRE&gt;&lt;P&gt;I want to print the report showing MM/DD/YYYY date format and AM/PM date format, and my code is below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data Earthquakes;
infile "path to .txt file";
input Date yymmdd10. Time time11. Magnitude $ Latitude Longitude $;
format Date mmddyy10. Time timeampm.;
run;

proc print data = Earthquakes;
run;&lt;/PRE&gt;&lt;P&gt;However, the output cuts off the milliseconds part of Time, rounds it to the nearest integer, and then puts it in the Magnitude column. The output looks something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV&gt;&lt;DIV align="center"&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sas_ss_equake.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/101589i8189C307F57B4912/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sas_ss_equake.png" alt="sas_ss_equake.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="lia-align-left"&gt;Why is the milliseconds part of time being put in the magnitude column, and then shifting every input one column over? How can I revise the code to show the time in AM/PM while having the correct entries in the magnitude, latitude, and longitude columns?&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 21 Oct 2024 01:51:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-is-the-time-truncating-and-how-do-I-fix-it/m-p/948302#M371075</guid>
      <dc:creator>unwashedhelimix</dc:creator>
      <dc:date>2024-10-21T01:51:04Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the time truncating and how do I fix it?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-is-the-time-truncating-and-how-do-I-fix-it/m-p/948305#M371076</link>
      <description>&lt;P&gt;Using right input method(list input) and pick up the right format .&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Earthquakes;
infile cards truncover;
input Date : yymmdd12. Time : time14. Magnitude  Latitude  Longitude ;
format Date mmddyy10. Time timeampm18.2 Magnitude f10.2  Latitude  Longitude f12.3;
cards;
2022/01/10 14:54:28.81 0.36 33.512 -116.768  
2022/01/10 15:16:32.60 0.96 33.184 -116.031   
2022/01/10 15:43:09.41 1.09 35.680 -117.535   
2022/01/10 16:33:07.48 0.68 33.588 -116.808 
2022/01/10 17:14:17.90 0.86 36.032 -117.807 
2022/01/10 18:00:07.32 0.61 35.765 -117.580 
2022/01/10 18:50:47.06 0.90 35.586 -117.462   
2022/01/10 18:59:47.00 2.61 35.648 -115.927 
;
run;

proc print data = Earthquakes;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1729476697239.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/101590iC3AFF4B3F46776FD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1729476697239.png" alt="Ksharp_0-1729476697239.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2024 02:11:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-is-the-time-truncating-and-how-do-I-fix-it/m-p/948305#M371076</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-10-21T02:11:50Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the time truncating and how do I fix it?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-is-the-time-truncating-and-how-do-I-fix-it/m-p/948320#M371082</link>
      <description>&lt;P&gt;Count the columns.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use the LIST statement to have SAS print it out for you to the SAS log.&lt;/P&gt;
&lt;PRE&gt;RULE:     ----+----1----+----2----+----3----+----4----+----5-
1         2022/01/10 14:54:28.81 0.36 33.512 -116.768 43
2         2022/01/10 15:16:32.60 0.96 33.184 -116.031 43
3         2022/01/10 15:43:09.41 1.09 35.680 -117.535 43
4         2022/01/10 16:33:07.48 0.68 33.588 -116.808 43
5         2022/01/10 17:14:17.90 0.86 36.032 -117.807 43
6         2022/01/10 18:00:07.32 0.61 35.765 -117.580 43
7         2022/01/10 18:50:47.06 0.90 35.586 -117.462 43
8         2022/01/10 18:59:47.00 2.61 35.648 -115.927 43
NOTE: 8 records were read from the infile HAVE.
      The minimum record length was 43.
      The maximum record length was 43.
&lt;/PRE&gt;
&lt;P&gt;You asked the INPUT statement to read the first two variables using FORMATTED MODE and the other three variables using LIST MODE.&amp;nbsp; So it read DATE from columns 1 to 10. Then TIME from columns 11 to 21 leaving the pointer at column 22.&amp;nbsp; So for MAGNITUDE it read the last digit of the TIME value.&amp;nbsp; And you never read in the last value on the line.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So either adjust the width of the TIME informat to account for the leading and trailing space.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input Date yymmdd10. Time time13. Magnitude Latitude Longitude;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or if the values are not in fixed column locations, but every field has a value on every line (with single periods used to mark the missing values) then just use LIST MODE for all of the fields instead of just the last three.&amp;nbsp; You could use an INFORMAT statement to attach the desired informats to DATE and TIME.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile have truncover;
  input Date Time Magnitude Latitude Longitude;
  informat date yymmdd. time time.;
  format date yymmdd10. time timeampm14.2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or instead if you want to specify the informat in-line in the INPUT statement then make sure to use the colon modifier so that the INPUT statement still uses LIST MODE instead of switching to FORMATTED MODE for those variables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  input Date :yymmdd. Time :time. Magnitude Latitude Longitude;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Remember that in LIST MODE input the width attached to the informat specification is ignored.&amp;nbsp; Instead the whole next field on the line is read, however many bytes it takes.&amp;nbsp; So no need to specify any width at all.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To display 8 character time values with a decimal point and two places to the right of the decimal point and a space and two letter suffix will requried using the format specification timeampm14.2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2024 04:14:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-is-the-time-truncating-and-how-do-I-fix-it/m-p/948320#M371082</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-10-21T04:14:09Z</dc:date>
    </item>
  </channel>
</rss>

