<?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: Copying cell values in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Copying-cell-values/m-p/286961#M8167</link>
    <description>&lt;P&gt;OK.&amp;nbsp; Most solutions will assume that the data is in order such as BY TRIP_ID.&amp;nbsp; If that's not possible, more difficult approaches are possible.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There also may be different&amp;nbsp; BUNDLE values within the same TRIP_ID that will get replaced with a common value.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At any rate here's one possibility that assumes a sorted order:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;do until (last.TRIP_ID);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; by trip_ID;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; if bundle &amp;gt; ' ' then replacement_bundle=bundle;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;do until (last.TRIP_ID);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; by trip_ID;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;drop bundle;&lt;/P&gt;
&lt;P&gt;rename replacement_bundle=bundle;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The top loop finds a nonmissing BUNDLE for that TRIP_ID.&amp;nbsp; The bottonm loop reads the same observations and uses that nonmissing value as a replacement value.&lt;/P&gt;</description>
    <pubDate>Mon, 25 Jul 2016 18:02:34 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2016-07-25T18:02:34Z</dc:date>
    <item>
      <title>Copying cell values</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Copying-cell-values/m-p/286928#M8162</link>
      <description>&lt;P&gt;I am trying to copy one cell to the next cell when another column has the same value.&amp;nbsp; I have been using this code, but it doesn't seem to be working the way i want.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; TRIP_ID=Lag(TRIP_ID) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; CHRG_CD=lag(CHRG_CD);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;The trip_ID is 349333&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;10791391&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;349333&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;10791390&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;349333&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;3892B&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;10791390&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;349333&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;3892B&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2016 16:40:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Copying-cell-values/m-p/286928#M8162</guid>
      <dc:creator>Raj21</dc:creator>
      <dc:date>2016-07-25T16:40:05Z</dc:date>
    </item>
    <item>
      <title>Re: Copying cell values</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Copying-cell-values/m-p/286945#M8163</link>
      <description>&lt;P&gt;That's a common mistake.&amp;nbsp; The LAG function does not retrieve the value from the previous observation.&amp;nbsp; It actually does something a little bit different.&amp;nbsp; It retrieves the value from the last time that the LAG function executed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Fixing this will be relatively simple.&amp;nbsp; But you need to provide a little more information.&amp;nbsp; In the data you provided, what are the column names?&amp;nbsp; What end result would you like to see?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2016 17:27:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Copying-cell-values/m-p/286945#M8163</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-07-25T17:27:43Z</dc:date>
    </item>
    <item>
      <title>Re: Copying cell values</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Copying-cell-values/m-p/286947#M8164</link>
      <description>The first column is Load Leg, the second column is Trip ID and the third column is Bundle. For this observation I would like it to use the Trip id which would be the same and copy the bundle value. There are many more observations, so I would want that logic for the whole table.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 25 Jul 2016 17:30:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Copying-cell-values/m-p/286947#M8164</guid>
      <dc:creator>Raj21</dc:creator>
      <dc:date>2016-07-25T17:30:20Z</dc:date>
    </item>
    <item>
      <title>Re: Copying cell values</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Copying-cell-values/m-p/286953#M8165</link>
      <description>&lt;P&gt;So where does CHRG_CD come into the program?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you trying to fill in the blank cell with the later value from Bundle?&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2016 17:36:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Copying-cell-values/m-p/286953#M8165</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-07-25T17:36:05Z</dc:date>
    </item>
    <item>
      <title>Re: Copying cell values</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Copying-cell-values/m-p/286959#M8166</link>
      <description>Sorry CHRG_CD is bundle and yes that is what I would be trying to do .&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 25 Jul 2016 17:55:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Copying-cell-values/m-p/286959#M8166</guid>
      <dc:creator>Raj21</dc:creator>
      <dc:date>2016-07-25T17:55:20Z</dc:date>
    </item>
    <item>
      <title>Re: Copying cell values</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Copying-cell-values/m-p/286961#M8167</link>
      <description>&lt;P&gt;OK.&amp;nbsp; Most solutions will assume that the data is in order such as BY TRIP_ID.&amp;nbsp; If that's not possible, more difficult approaches are possible.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There also may be different&amp;nbsp; BUNDLE values within the same TRIP_ID that will get replaced with a common value.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At any rate here's one possibility that assumes a sorted order:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;do until (last.TRIP_ID);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; by trip_ID;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; if bundle &amp;gt; ' ' then replacement_bundle=bundle;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;do until (last.TRIP_ID);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; by trip_ID;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;drop bundle;&lt;/P&gt;
&lt;P&gt;rename replacement_bundle=bundle;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The top loop finds a nonmissing BUNDLE for that TRIP_ID.&amp;nbsp; The bottonm loop reads the same observations and uses that nonmissing value as a replacement value.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2016 18:02:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Copying-cell-values/m-p/286961#M8167</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-07-25T18:02:34Z</dc:date>
    </item>
    <item>
      <title>Re: Copying cell values</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Copying-cell-values/m-p/286978#M8168</link>
      <description>I can organize this by Trip_ID, that shouldn't be a problem. That do loop worked like a charm, thank you very much!&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 25 Jul 2016 18:28:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Copying-cell-values/m-p/286978#M8168</guid>
      <dc:creator>Raj21</dc:creator>
      <dc:date>2016-07-25T18:28:52Z</dc:date>
    </item>
  </channel>
</rss>

