<?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 Copying numerical data between observations in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Copying-numerical-data-between-observations/m-p/137979#M27886</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a dataset sorted by three variables, and I'm trying to copy another variable from the previous observation within each grouping conditional on whether the variable has a value or not. So far, here's the code that I have:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA test3;&lt;/P&gt;&lt;P&gt;length V1 8;&lt;/P&gt;&lt;P&gt;Set FuelCost11;&lt;/P&gt;&lt;P&gt;By PlantID PMStd Fuel;&lt;/P&gt;&lt;P&gt;Retain V1;&lt;/P&gt;&lt;P&gt;if first.Fuel then V1 = .;&lt;/P&gt;&lt;P&gt;if HeatRate ^=. then V1 = HeatRate;&lt;/P&gt;&lt;P&gt;HeatRate = V1;&lt;/P&gt;&lt;P&gt;Run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I run this code, I get the following error:&lt;/P&gt;&lt;P&gt;"ERROR: Variable V1 has been defined as both character and numeric."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't know why this would happen, since I'm defining the variable V1 as a numerical variable in the first statement of the data step. The variable V1 doesn't exist prior to this data step. I've run this same code with a character variable (after defining V1 as $5), and it works perfectly. Thanks in advance for any help you can provide.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Jan 2014 20:15:32 GMT</pubDate>
    <dc:creator>ebowen</dc:creator>
    <dc:date>2014-01-10T20:15:32Z</dc:date>
    <item>
      <title>Copying numerical data between observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copying-numerical-data-between-observations/m-p/137979#M27886</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a dataset sorted by three variables, and I'm trying to copy another variable from the previous observation within each grouping conditional on whether the variable has a value or not. So far, here's the code that I have:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA test3;&lt;/P&gt;&lt;P&gt;length V1 8;&lt;/P&gt;&lt;P&gt;Set FuelCost11;&lt;/P&gt;&lt;P&gt;By PlantID PMStd Fuel;&lt;/P&gt;&lt;P&gt;Retain V1;&lt;/P&gt;&lt;P&gt;if first.Fuel then V1 = .;&lt;/P&gt;&lt;P&gt;if HeatRate ^=. then V1 = HeatRate;&lt;/P&gt;&lt;P&gt;HeatRate = V1;&lt;/P&gt;&lt;P&gt;Run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I run this code, I get the following error:&lt;/P&gt;&lt;P&gt;"ERROR: Variable V1 has been defined as both character and numeric."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't know why this would happen, since I'm defining the variable V1 as a numerical variable in the first statement of the data step. The variable V1 doesn't exist prior to this data step. I've run this same code with a character variable (after defining V1 as $5), and it works perfectly. Thanks in advance for any help you can provide.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Jan 2014 20:15:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copying-numerical-data-between-observations/m-p/137979#M27886</guid>
      <dc:creator>ebowen</dc:creator>
      <dc:date>2014-01-10T20:15:32Z</dc:date>
    </item>
    <item>
      <title>Re: Copying numerical data between observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copying-numerical-data-between-observations/m-p/137980#M27887</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What variable type is HeatRate? Your missing a period after the eight in the length statement, not sure if thats an issue as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you post proc contents results on FuelCost11?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Jan 2014 20:21:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copying-numerical-data-between-observations/m-p/137980#M27887</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-01-10T20:21:24Z</dc:date>
    </item>
    <item>
      <title>Re: Copying numerical data between observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copying-numerical-data-between-observations/m-p/137981#M27888</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It turns out I had defined V1 previously as a character variable. After fixing that, the code works great. Sorry for the mix-up.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Jan 2014 20:40:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copying-numerical-data-between-observations/m-p/137981#M27888</guid>
      <dc:creator>ebowen</dc:creator>
      <dc:date>2014-01-10T20:40:40Z</dc:date>
    </item>
    <item>
      <title>Re: Copying numerical data between observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copying-numerical-data-between-observations/m-p/137982#M27889</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why would you need a period after 8 in the length statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Jan 2014 21:39:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copying-numerical-data-between-observations/m-p/137982#M27889</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2014-01-10T21:39:03Z</dc:date>
    </item>
    <item>
      <title>Re: Copying numerical data between observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copying-numerical-data-between-observations/m-p/137983#M27890</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I realized that and deleted it...but the forums are having issues today...or maybe I am. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Jan 2014 22:33:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copying-numerical-data-between-observations/m-p/137983#M27890</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-01-10T22:33:29Z</dc:date>
    </item>
  </channel>
</rss>

