<?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: merging data across variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/merging-data-across-variables/m-p/676451#M203970</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;11	13MAR20:09:10:41	95	1 35
11	13MAR20:09:12:41	28	2 28
14	13MAR20:09:10:41	50	1 50
14	13MAR20:09:12:41	10	2 10
14	13MAR20:09:13:41	90	3 30&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Expected outcome&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 13 Aug 2020 11:33:53 GMT</pubDate>
    <dc:creator>Joostvanerp</dc:creator>
    <dc:date>2020-08-13T11:33:53Z</dc:date>
    <item>
      <title>merging data across variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merging-data-across-variables/m-p/676438#M203960</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to transfom my dataset for further analysis.&lt;BR /&gt;The goal is to get the data together with the same selectionnumber, to summate the intervals with the same selection numbers, except for the last interval with that selectionnumber. In stead of the interval, the seconds of that line needs to be used in the place of the interval in the summation.&lt;BR /&gt;I can't get it working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BR, Joost&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* input dataset */
data test(drop=datetm rename=(datetm1=datetm));
length cownum 8 datetm $ 16 interval 8 selectionnm 8 seconds;
infile datalines dsd dlm="09"x;
input cownum  datetm $ interval  selectionnm seconds;
/* As datetime is in character,it needs to be traslated into datetime */
datetm1=input(datetm,datetime.);
format datetm1 nldatm48.;
cards;
11	13MAR20:09:10:41	14	1 10
11	13MAR20:09:10:55	46	1 20
11	13MAR20:09:11:41	60	1 35
11	13MAR20:09:12:41	35	2 28
14	13MAR20:09:10:41	120	1 50
14	13MAR20:09:12:41	60	2 10
14	13MAR20:09:13:41	60	3 40
14	13MAR20:09:14:41	35	3 30
;
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Aug 2020 10:14:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merging-data-across-variables/m-p/676438#M203960</guid>
      <dc:creator>Joostvanerp</dc:creator>
      <dc:date>2020-08-13T10:14:28Z</dc:date>
    </item>
    <item>
      <title>Re: merging data across variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merging-data-across-variables/m-p/676439#M203961</link>
      <description>&lt;P&gt;So you want to keep all observations, but with a running summation of intervals, except for the last observation in a group?&lt;/P&gt;</description>
      <pubDate>Thu, 13 Aug 2020 10:26:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merging-data-across-variables/m-p/676439#M203961</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-08-13T10:26:06Z</dc:date>
    </item>
    <item>
      <title>Re: merging data across variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merging-data-across-variables/m-p/676441#M203963</link>
      <description>&lt;P&gt;You should supply an expected outcome for the data you posted.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Aug 2020 10:34:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merging-data-across-variables/m-p/676441#M203963</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-08-13T10:34:38Z</dc:date>
    </item>
    <item>
      <title>Re: merging data across variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merging-data-across-variables/m-p/676451#M203970</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;11	13MAR20:09:10:41	95	1 35
11	13MAR20:09:12:41	28	2 28
14	13MAR20:09:10:41	50	1 50
14	13MAR20:09:12:41	10	2 10
14	13MAR20:09:13:41	90	3 30&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Expected outcome&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Aug 2020 11:33:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merging-data-across-variables/m-p/676451#M203970</guid>
      <dc:creator>Joostvanerp</dc:creator>
      <dc:date>2020-08-13T11:33:53Z</dc:date>
    </item>
    <item>
      <title>Re: merging data across variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merging-data-across-variables/m-p/676455#M203973</link>
      <description>&lt;P&gt;Then this code does it:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input cownum datetm :datetime. interval selectionnm seconds;
format datetm datetime19.;
cards;
11  13MAR20:09:10:41  14  1 10
11  13MAR20:09:10:55  46  1 20
11  13MAR20:09:11:41  60  1 35
11  13MAR20:09:12:41  35  2 28
14  13MAR20:09:10:41  120 1 50
14  13MAR20:09:12:41  60  2 10
14  13MAR20:09:13:41  60  3 40
14  13MAR20:09:14:41  35  3 30
;

data want;
retain cownum datetm interval selectionnm seconds;
format datetm datetime19.;
retain datetm;
set have (rename=(datetm=_datetm interval=_int));
by cownum selectionnm;
if first.selectionnm
then do;
  datetm = _datetm;
  interval = ifn(last.selectionnm,seconds,_int);
end;
else interval + ifn(last.selectionnm,seconds,_int);
if last.selectionnm;
drop _:;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Aug 2020 11:45:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merging-data-across-variables/m-p/676455#M203973</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-08-13T11:45:20Z</dc:date>
    </item>
  </channel>
</rss>

