<?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: creating new variable with observation value in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/creating-new-variable-with-observation-value/m-p/571139#M12097</link>
    <description>&lt;P&gt;You want a new observation with company = 'Total' and profit = sum of profits?&lt;/P&gt;
&lt;P&gt;This is mostly needed for reporting, and the SAS procedures for that can handle it, so there's no need to add an observation.&lt;/P&gt;
&lt;P&gt;But just to show you how it's done:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have end=eof;
retain sum_profit 0;
output;
sum_profit + profit;
if eof
then do;
  company = 'Total';
  profit = sum_profit;
  output;
end;
drop sum_profit;
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 04 Jul 2019 05:38:24 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2019-07-04T05:38:24Z</dc:date>
    <item>
      <title>creating new variable with observation value</title>
      <link>https://communities.sas.com/t5/New-SAS-User/creating-new-variable-with-observation-value/m-p/571137#M12096</link>
      <description>Hi i have below data set&lt;BR /&gt;Company Profit&lt;BR /&gt;OYO 45&lt;BR /&gt;PAYTM 65&lt;BR /&gt;PHONPE 50&lt;BR /&gt;Total 160&lt;BR /&gt;&lt;BR /&gt;in the above dataset I want add new varibale Total where i want total value 160. I do not want to create variable by giving hard value as&lt;BR /&gt;&lt;BR /&gt;Total=160&lt;BR /&gt;I want to create in such a way that if total value changes then variable value also changes accordingly&lt;BR /&gt;Can someone advise please&lt;BR /&gt;</description>
      <pubDate>Thu, 04 Jul 2019 05:32:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/creating-new-variable-with-observation-value/m-p/571137#M12096</guid>
      <dc:creator>Kamal5522</dc:creator>
      <dc:date>2019-07-04T05:32:58Z</dc:date>
    </item>
    <item>
      <title>Re: creating new variable with observation value</title>
      <link>https://communities.sas.com/t5/New-SAS-User/creating-new-variable-with-observation-value/m-p/571139#M12097</link>
      <description>&lt;P&gt;You want a new observation with company = 'Total' and profit = sum of profits?&lt;/P&gt;
&lt;P&gt;This is mostly needed for reporting, and the SAS procedures for that can handle it, so there's no need to add an observation.&lt;/P&gt;
&lt;P&gt;But just to show you how it's done:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have end=eof;
retain sum_profit 0;
output;
sum_profit + profit;
if eof
then do;
  company = 'Total';
  profit = sum_profit;
  output;
end;
drop sum_profit;
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Jul 2019 05:38:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/creating-new-variable-with-observation-value/m-p/571139#M12097</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-07-04T05:38:24Z</dc:date>
    </item>
    <item>
      <title>Re: creating new variable with observation value</title>
      <link>https://communities.sas.com/t5/New-SAS-User/creating-new-variable-with-observation-value/m-p/571141#M12098</link>
      <description>thanks</description>
      <pubDate>Thu, 04 Jul 2019 05:54:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/creating-new-variable-with-observation-value/m-p/571141#M12098</guid>
      <dc:creator>Kamal5522</dc:creator>
      <dc:date>2019-07-04T05:54:10Z</dc:date>
    </item>
    <item>
      <title>Re: creating new variable with observation value</title>
      <link>https://communities.sas.com/t5/New-SAS-User/creating-new-variable-with-observation-value/m-p/571142#M12099</link>
      <description>Thanks kurt. this code is quite useful</description>
      <pubDate>Thu, 04 Jul 2019 05:56:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/creating-new-variable-with-observation-value/m-p/571142#M12099</guid>
      <dc:creator>Kamal5522</dc:creator>
      <dc:date>2019-07-04T05:56:25Z</dc:date>
    </item>
    <item>
      <title>Re: creating new variable with observation value</title>
      <link>https://communities.sas.com/t5/New-SAS-User/creating-new-variable-with-observation-value/m-p/571144#M12101</link>
      <description>Hi kurt&lt;BR /&gt;I also want to know that is it possible to create a variable with the particular observation value. if we change observation value then value of variable chnages. suppose in the below example if I want to create a varibale X that show paytm 65 value&lt;BR /&gt;company profit X&lt;BR /&gt;oyo 55 65&lt;BR /&gt;paytm 65 65&lt;BR /&gt;phone 40 65&lt;BR /&gt;if change paytm profit to 70 then whole X varibale should show 70.&lt;BR /&gt;please advise</description>
      <pubDate>Thu, 04 Jul 2019 06:02:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/creating-new-variable-with-observation-value/m-p/571144#M12101</guid>
      <dc:creator>Kamal5522</dc:creator>
      <dc:date>2019-07-04T06:02:24Z</dc:date>
    </item>
    <item>
      <title>Re: creating new variable with observation value</title>
      <link>https://communities.sas.com/t5/New-SAS-User/creating-new-variable-with-observation-value/m-p/571146#M12102</link>
      <description>&lt;P&gt;Do you want the maximum value in the new column, or the value of a specific observation?&lt;/P&gt;
&lt;P&gt;Maximum:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select
  have.*,
  max(profit) as X
from have;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Specific:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select
  have.*,
  (select profit from have where company = 'paytm') as X
from have;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Jul 2019 06:09:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/creating-new-variable-with-observation-value/m-p/571146#M12102</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-07-04T06:09:25Z</dc:date>
    </item>
  </channel>
</rss>

