<?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: Create new variable in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Create-new-variable/m-p/677976#M23798</link>
    <description>Perfect, thank you a lot &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;!&lt;BR /&gt;&lt;BR /&gt;All best&lt;BR /&gt;MM</description>
    <pubDate>Thu, 20 Aug 2020 07:38:33 GMT</pubDate>
    <dc:creator>Mikkel_madsen</dc:creator>
    <dc:date>2020-08-20T07:38:33Z</dc:date>
    <item>
      <title>Create new variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-new-variable/m-p/677971#M23796</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the following data:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Activation&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Complete&lt;/P&gt;
&lt;P&gt;02SEP2018:08:07:12&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;02SEP2018:08:13:04&lt;/P&gt;
&lt;P&gt;09SEP2018:15:03:33&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;09SEP2018:15:10:00&lt;/P&gt;
&lt;P&gt;15SEP2018:21:22:23&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;15SEP2018:21:33:55&lt;/P&gt;
&lt;P&gt;14JAN2019:04:03:03&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;14JAN2019:04:07:10&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The "Activation" is format datetime19. and the "Complete" is datetime16. with informat datetime26.7&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to create a new variable called "Difference" that calculate the timedifference between Activation and Complete. It should be in the format time8, so I am only interested in the timedifference in hour:min:sec (no dates e.g. 14JAN).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope someone can help!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you in advance.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Aug 2020 07:12:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-new-variable/m-p/677971#M23796</guid>
      <dc:creator>Mikkel_madsen</dc:creator>
      <dc:date>2020-08-20T07:12:27Z</dc:date>
    </item>
    <item>
      <title>Re: Create new variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-new-variable/m-p/677975#M23797</link>
      <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input (Activation Complete)(:datetime26.7);
format Activation Complete datetime16.;
datalines;
02SEP2018:08:07:12 02SEP2018:08:13:04
09SEP2018:15:03:33 09SEP2018:15:10:00
15SEP2018:21:22:23 15SEP2018:21:33:55
14JAN2019:04:03:03 14JAN2019:04:07:10
;

data want;
   set have;
   Difference = Complete - Activation;
   format Difference time8.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Aug 2020 07:20:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-new-variable/m-p/677975#M23797</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-08-20T07:20:56Z</dc:date>
    </item>
    <item>
      <title>Re: Create new variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-new-variable/m-p/677976#M23798</link>
      <description>Perfect, thank you a lot &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;!&lt;BR /&gt;&lt;BR /&gt;All best&lt;BR /&gt;MM</description>
      <pubDate>Thu, 20 Aug 2020 07:38:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-new-variable/m-p/677976#M23798</guid>
      <dc:creator>Mikkel_madsen</dc:creator>
      <dc:date>2020-08-20T07:38:33Z</dc:date>
    </item>
    <item>
      <title>Re: Create new variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-new-variable/m-p/677978#M23799</link>
      <description>&lt;P&gt;If your time different es could run across several days, I suggest to use a larger value for the TIME format, as SAS can display more than 2 digits for hours:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input (Activation Complete)(:datetime26.7);
format Activation Complete datetime16.;
datalines;
02SEP2018:08:07:12 08SEP2018:08:13:04
;

data want;
   set have;
   Difference = Complete - Activation;
   format Difference time9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Aug 2020 07:41:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-new-variable/m-p/677978#M23799</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-08-20T07:41:27Z</dc:date>
    </item>
    <item>
      <title>Re: Create new variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-new-variable/m-p/678840#M23889</link>
      <description>&lt;P&gt;Thanks to both of you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I want to calculate the mean difference I have tried the following code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC MEANS data=have
N Mean median min max Q1 Q3 nmiss maxdec=2;
VAR Difference;
Run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It returns the mean, meadian, min, max, Q1, and Q3 in seconds. Can it be displayed in min:sec instead?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Aug 2020 10:27:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-new-variable/m-p/678840#M23889</guid>
      <dc:creator>Mikkel_madsen</dc:creator>
      <dc:date>2020-08-24T10:27:31Z</dc:date>
    </item>
    <item>
      <title>Re: Create new variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-new-variable/m-p/678843#M23890</link>
      <description>&lt;P&gt;Use the &lt;A href="https://documentation.sas.com/?docsetId=ds2ref&amp;amp;docsetTarget=n19wtlryjny0mtn1q6vmccolhry5.htm&amp;amp;docsetVersion=3.1&amp;amp;locale=en" target="_self"&gt;MMSS Format&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Aug 2020 10:35:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-new-variable/m-p/678843#M23890</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-08-24T10:35:01Z</dc:date>
    </item>
    <item>
      <title>Re: Create new variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-new-variable/m-p/678845#M23891</link>
      <description>Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;. Unfortunately, it won't work for me. I'm not sure how to incorporate the MMSS format in the code. Can you elaborate?</description>
      <pubDate>Mon, 24 Aug 2020 10:53:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-new-variable/m-p/678845#M23891</guid>
      <dc:creator>Mikkel_madsen</dc:creator>
      <dc:date>2020-08-24T10:53:49Z</dc:date>
    </item>
    <item>
      <title>Re: Create new variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-new-variable/m-p/679080#M23919</link>
      <description>&lt;P&gt;MEANS and SUMMARY provide no direct way to format your VAR variables, but you can use PROC TEMPLATE to do this through ODS:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* create sample data */
data test;
input amount ;
cards;
1000
12345
8500
;
run;
 
/* Modify the base.summary table template using */
/* EDIT statements. */
ods path(prepend) work.templat(update);
proc template;
 edit base.summary;
  edit mean;
   format=dollar12.2;
  end;
  edit sum;
   format=dollar12.;
  end;
 end;
run;
 
proc means data=test n mean sum;
var amount;
run;
 
/* restore default template */
proc template;
 delete base.summary;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This example was taken from&amp;nbsp;&lt;A href="https://blogs.sas.com/content/sgf/2015/07/17/customizing-output-from-proc-means/" target="_blank" rel="noopener"&gt;https://blogs.sas.com/content/sgf/2015/07/17/customizing-output-from-proc-means/&lt;/A&gt;, found through a Google search for "sas proc means use format" (third result); see Maxim 6.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another way is to create an output dataset from MEANS, and then use PROC REPORT to have a nicely formatted report.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Aug 2020 07:05:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-new-variable/m-p/679080#M23919</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-08-25T07:05:33Z</dc:date>
    </item>
    <item>
      <title>Re: Create new variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-new-variable/m-p/679081#M23920</link>
      <description>&lt;P&gt;Complete code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input (Activation Complete)(:datetime26.7);
format Activation Complete datetime16.;
datalines;
02SEP2018:08:07:12 02SEP2018:08:13:04
09SEP2018:15:03:33 09SEP2018:15:10:00
15SEP2018:21:22:23 15SEP2018:21:33:55
14JAN2019:04:03:03 14JAN2019:04:07:10
;

data want;
set have;
Difference = Complete - Activation;
format Difference mmss8.;
run;

ods path(prepend) work.templat(update);

proc template;
edit base.summary;
  edit mean;
    format=mmss8.;
  end;
  edit median;
    format=mmss8.;
  end;
  edit min;
    format=mmss8.;
  end;
  edit max;
    format=mmss8.;
  end;
  edit q1;
    format=mmss8.;
  end;
  edit q3;
    format=mmss8.;
  end;
end;
run;

proc means
  data=want
  n mean median min max Q1 Q3
  nmiss
  maxdec=2
;
var Difference;
run;

proc template;
delete base.summary;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Aug 2020 07:23:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-new-variable/m-p/679081#M23920</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-08-25T07:23:08Z</dc:date>
    </item>
    <item>
      <title>Re: Create new variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-new-variable/m-p/679140#M23923</link>
      <description>Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt; - it seems to work perfectly!</description>
      <pubDate>Tue, 25 Aug 2020 12:35:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-new-variable/m-p/679140#M23923</guid>
      <dc:creator>Mikkel_madsen</dc:creator>
      <dc:date>2020-08-25T12:35:05Z</dc:date>
    </item>
  </channel>
</rss>

