<?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: Manipulate data by ID in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Manipulate-data-by-ID/m-p/613000#M18563</link>
    <description>&lt;P&gt;Please supply example data in a data step with datalines, as you have been shown in&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Create-variable-by-ID-and-based-on-another-variable/m-p/583609" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Programming/Create-variable-by-ID-and-based-on-another-variable/m-p/583609&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Excel files can not convey important attributes of SAS data, and make it harder for us to recreate your data. Data steps are unambiguous.&lt;/P&gt;</description>
    <pubDate>Thu, 19 Dec 2019 12:15:34 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2019-12-19T12:15:34Z</dc:date>
    <item>
      <title>Manipulate data by ID</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Manipulate-data-by-ID/m-p/612996#M18562</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to manipulate the data by ID, so that the variable "start" always takes the value of lag "end", except for the first value which is 0. The "end" variable also has to be adjusted accordingly. Please see attached what I mean.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much!&lt;/P&gt;</description>
      <pubDate>Thu, 19 Dec 2019 12:05:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Manipulate-data-by-ID/m-p/612996#M18562</guid>
      <dc:creator>blackandwhite</dc:creator>
      <dc:date>2019-12-19T12:05:01Z</dc:date>
    </item>
    <item>
      <title>Re: Manipulate data by ID</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Manipulate-data-by-ID/m-p/613000#M18563</link>
      <description>&lt;P&gt;Please supply example data in a data step with datalines, as you have been shown in&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Create-variable-by-ID-and-based-on-another-variable/m-p/583609" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Programming/Create-variable-by-ID-and-based-on-another-variable/m-p/583609&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Excel files can not convey important attributes of SAS data, and make it harder for us to recreate your data. Data steps are unambiguous.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Dec 2019 12:15:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Manipulate-data-by-ID/m-p/613000#M18563</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-12-19T12:15:34Z</dc:date>
    </item>
    <item>
      <title>Re: Manipulate data by ID</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Manipulate-data-by-ID/m-p/613007#M18564</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/166182"&gt;@blackandwhite&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can try this. Let me know if that does correspond to what you want.&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
	set have;
	
	by ID;
	
	dif = end - start;
	
	if first.ID then end2 = 0;
	end2 + dif;
	
	start2 = lag(end2);
	if first.ID then start2 = 0;

	drop start end dif;
	rename start2 = start end2 = end;
	
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Dec 2019 12:38:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Manipulate-data-by-ID/m-p/613007#M18564</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2019-12-19T12:38:40Z</dc:date>
    </item>
    <item>
      <title>Re: Manipulate data by ID</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Manipulate-data-by-ID/m-p/613032#M18565</link>
      <description>&lt;P&gt;works great- thanks very much!!&lt;/P&gt;</description>
      <pubDate>Thu, 19 Dec 2019 13:47:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Manipulate-data-by-ID/m-p/613032#M18565</guid>
      <dc:creator>blackandwhite</dc:creator>
      <dc:date>2019-12-19T13:47:29Z</dc:date>
    </item>
    <item>
      <title>Re: Manipulate data by ID</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Manipulate-data-by-ID/m-p/613034#M18566</link>
      <description>&lt;P&gt;Ok - will do next time, thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Dec 2019 13:48:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Manipulate-data-by-ID/m-p/613034#M18566</guid>
      <dc:creator>blackandwhite</dc:creator>
      <dc:date>2019-12-19T13:48:25Z</dc:date>
    </item>
    <item>
      <title>Re: Manipulate data by ID</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Manipulate-data-by-ID/m-p/613066#M18567</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/166182"&gt;@blackandwhite&lt;/a&gt;&amp;nbsp; Sorry late to the party as I missed to see this question. Oh well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If i understand correctly, one temp variable gymnastic alone should do&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input ID	start	end;
cards;
1	0	6
1	11	17
1	17	25
2	0	5
2	5	10
2	10	18
;

data want;
set have;
by id;
end=ifn(not first.id,sum(_iorc_,end-start,0),end);
start=ifn(not first.id,_iorc_,start);
_iorc_=end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Dec 2019 15:18:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Manipulate-data-by-ID/m-p/613066#M18567</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-12-19T15:18:20Z</dc:date>
    </item>
    <item>
      <title>Re: Manipulate data by ID</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Manipulate-data-by-ID/m-p/613072#M18568</link>
      <description>&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;, works great, thanks very much.&lt;/P&gt;&lt;P&gt;Can't complain about having several options &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Dec 2019 15:38:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Manipulate-data-by-ID/m-p/613072#M18568</guid>
      <dc:creator>blackandwhite</dc:creator>
      <dc:date>2019-12-19T15:38:06Z</dc:date>
    </item>
  </channel>
</rss>

