<?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: PROC SQL with TIME manipulation in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-with-TIME-manipulation/m-p/458262#M70167</link>
    <description>&lt;P&gt;Can you include some sample data and expected output?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/205375"&gt;@alterman1&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I'm working with instrumentation data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have several problems that I don't know how to deal with.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have some records that contain time values.&amp;nbsp; They aren't clock times, they are durations (like elapsed time).&amp;nbsp; &amp;nbsp;I've looked through a bunch of SAS doc and I haven't found what I'm looking for.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to proc contents, the fields are defined 'num 5' and they have formats of time12.2.&amp;nbsp; &amp;nbsp;I want to use PROC SQL for a series of queries that I need to run.&amp;nbsp; &amp;nbsp;I need to do two things.&amp;nbsp; I need to add several time variables on each row, subtract that result from another time variable on that row, and then I need to sum those rows - to compute various totals.&amp;nbsp; This is the general problem, but I want to take this one step further and unclutter my SQL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;sql;&lt;/P&gt;
&lt;P&gt;select&lt;/P&gt;
&lt;P&gt;&amp;nbsp; datepart(smftime) as system_date format yymmddd10.,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; qwhsssid as ssid,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; sum(qpactjst) as cpu_time,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; count(*) as count&lt;/P&gt;
&lt;P&gt;from db2acctp&lt;/P&gt;
&lt;P&gt;where qwhsssid = 'DB2A'&lt;/P&gt;
&lt;P&gt;group by ssid, system_date&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The SQL above is from a different thread and this is a question for the having to do with this question and SQL I copied into this thread.&amp;nbsp; The main reason I'm asking this is when I start adding fields to my SQL, it's going to be a cluttered mess.&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, my second question is whether there is a way in SAS, that I can declare the format of a column ahead of the SQL so that I only need the column (and may the 'AS' verb) in the SQL.&amp;nbsp; For this thread, I'm going to have to sum 10 variables and then subtract these 10 variables from another variable to get this value for every row and take the results (about 100K rows) and sum the result like the SQL above.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 27 Apr 2018 20:58:55 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-04-27T20:58:55Z</dc:date>
    <item>
      <title>PROC SQL with TIME manipulation</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-with-TIME-manipulation/m-p/458261#M70166</link>
      <description>&lt;P&gt;I'm working with instrumentation data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have several problems that I don't know how to deal with.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have some records that contain time values.&amp;nbsp; They aren't clock times, they are durations (like elapsed time).&amp;nbsp; &amp;nbsp;I've looked through a bunch of SAS doc and I haven't found what I'm looking for.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;According to proc contents, the fields are defined 'num 5' and they have formats of time12.2.&amp;nbsp; &amp;nbsp;I want to use PROC SQL for a series of queries that I need to run.&amp;nbsp; &amp;nbsp;I need to do two things.&amp;nbsp; I need to add several time variables on each row, subtract that result from another time variable on that row, and then I need to sum those rows - to compute various totals.&amp;nbsp; This is the general problem, but I want to take this one step further and unclutter my SQL.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;sql;&lt;/P&gt;&lt;P&gt;select&lt;/P&gt;&lt;P&gt;&amp;nbsp; datepart(smftime) as system_date format yymmddd10.,&lt;/P&gt;&lt;P&gt;&amp;nbsp; qwhsssid as ssid,&lt;/P&gt;&lt;P&gt;&amp;nbsp; sum(qpactjst) as cpu_time,&lt;/P&gt;&lt;P&gt;&amp;nbsp; count(*) as count&lt;/P&gt;&lt;P&gt;from db2acctp&lt;/P&gt;&lt;P&gt;where qwhsssid = 'DB2A'&lt;/P&gt;&lt;P&gt;group by ssid, system_date&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The SQL above is from a different thread and this is a question for the having to do with this question and SQL I copied into this thread.&amp;nbsp; The main reason I'm asking this is when I start adding fields to my SQL, it's going to be a cluttered mess.&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, my second question is whether there is a way in SAS, that I can declare the format of a column ahead of the SQL so that I only need the column (and may the 'AS' verb) in the SQL.&amp;nbsp; For this thread, I'm going to have to sum 10 variables and then subtract these 10 variables from another variable to get this value for every row and take the results (about 100K rows) and sum the result like the SQL above.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Apr 2018 20:55:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-with-TIME-manipulation/m-p/458261#M70166</guid>
      <dc:creator>alterman1</dc:creator>
      <dc:date>2018-04-27T20:55:34Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL with TIME manipulation</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-with-TIME-manipulation/m-p/458262#M70167</link>
      <description>&lt;P&gt;Can you include some sample data and expected output?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/205375"&gt;@alterman1&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I'm working with instrumentation data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have several problems that I don't know how to deal with.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have some records that contain time values.&amp;nbsp; They aren't clock times, they are durations (like elapsed time).&amp;nbsp; &amp;nbsp;I've looked through a bunch of SAS doc and I haven't found what I'm looking for.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to proc contents, the fields are defined 'num 5' and they have formats of time12.2.&amp;nbsp; &amp;nbsp;I want to use PROC SQL for a series of queries that I need to run.&amp;nbsp; &amp;nbsp;I need to do two things.&amp;nbsp; I need to add several time variables on each row, subtract that result from another time variable on that row, and then I need to sum those rows - to compute various totals.&amp;nbsp; This is the general problem, but I want to take this one step further and unclutter my SQL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;sql;&lt;/P&gt;
&lt;P&gt;select&lt;/P&gt;
&lt;P&gt;&amp;nbsp; datepart(smftime) as system_date format yymmddd10.,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; qwhsssid as ssid,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; sum(qpactjst) as cpu_time,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; count(*) as count&lt;/P&gt;
&lt;P&gt;from db2acctp&lt;/P&gt;
&lt;P&gt;where qwhsssid = 'DB2A'&lt;/P&gt;
&lt;P&gt;group by ssid, system_date&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The SQL above is from a different thread and this is a question for the having to do with this question and SQL I copied into this thread.&amp;nbsp; The main reason I'm asking this is when I start adding fields to my SQL, it's going to be a cluttered mess.&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, my second question is whether there is a way in SAS, that I can declare the format of a column ahead of the SQL so that I only need the column (and may the 'AS' verb) in the SQL.&amp;nbsp; For this thread, I'm going to have to sum 10 variables and then subtract these 10 variables from another variable to get this value for every row and take the results (about 100K rows) and sum the result like the SQL above.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Apr 2018 20:58:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-with-TIME-manipulation/m-p/458262#M70167</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-04-27T20:58:55Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL with TIME manipulation</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-with-TIME-manipulation/m-p/458282#M70168</link>
      <description>&lt;P&gt;Concrete examples help. Depending on what your actual calculations need to be perhaps sql isn't the best approach.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If a variable is reported by contents as having a TIME format then the value is a number of seconds (and fractions of second). So adding durations is the total duration. The format controls how the value is displayed to us humans so we can look at it and say 4 hours and 8 minutes instead of having to do division and such.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You want to be careful using sql and Sum if attempting to add variables together as Sum in Sql is more of an aggregate across records function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps a data step is a better approach if you are worried about a "cluttered mess" in code. Arrays and variable lists, features not available in Proc SQL, may make the code for the first step&amp;nbsp;much cleaner.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Apr 2018 23:04:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-with-TIME-manipulation/m-p/458282#M70168</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-04-27T23:04:24Z</dc:date>
    </item>
  </channel>
</rss>

