<?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: Not able to compute a variable in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/Not-able-to-compute-a-variable/m-p/454197#M5238</link>
    <description>&lt;P&gt;Perfect thank you. I think, because I did not define it as display variable, SAS treated it as analysis variable as it was numeric datatype.&lt;/P&gt;&lt;P&gt;Due to SAS treating it as analysis variable it was not able to perform mathematical operation on it.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 14 Apr 2018 19:20:30 GMT</pubDate>
    <dc:creator>smartrambit0</dc:creator>
    <dc:date>2018-04-14T19:20:30Z</dc:date>
    <item>
      <title>Not able to compute a variable</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Not-able-to-compute-a-variable/m-p/454157#M5229</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to SAS analytics and running my code on "online sas studio". please let me know what is wrong with the code. I am getting missing value for the computed variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the dataset&lt;/P&gt;&lt;P&gt;--------------------------&lt;BR /&gt;data emp;&lt;BR /&gt;input id salary total weightr;&lt;BR /&gt;datalines;&lt;BR /&gt;1 2000 5000 20&lt;BR /&gt;2 3000 4000 30&lt;BR /&gt;3 5000 7000 44&lt;BR /&gt;4 2000 4000 55&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code&lt;/P&gt;&lt;P&gt;----------------------&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc report data=emp;&lt;BR /&gt;column id salary total weightr ratio;&lt;BR /&gt;define id / display;&lt;BR /&gt;define salary / 'salary';&lt;BR /&gt;define total / 'total';&lt;BR /&gt;define weightr / 'weight';&lt;BR /&gt;define ratio / computed 'ratio';&lt;/P&gt;&lt;P&gt;compute ratio;&lt;BR /&gt;ratio=round(weightr/2.2);&lt;BR /&gt;endcomp;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the output&lt;/P&gt;&lt;P&gt;--------------------------&lt;/P&gt;&lt;P&gt;id salary total weight ratio&lt;BR /&gt;1 2000 5000 20&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;BR /&gt;2 3000 4000 30&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;BR /&gt;3 5000 7000 44&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;BR /&gt;4 2000 4000 55&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to compute ratio as weight/2.2. Please suggest what is wrong with code here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Apr 2018 16:09:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Not-able-to-compute-a-variable/m-p/454157#M5229</guid>
      <dc:creator>smartrambit0</dc:creator>
      <dc:date>2018-04-14T16:09:35Z</dc:date>
    </item>
    <item>
      <title>Re: Not able to compute a variable</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Not-able-to-compute-a-variable/m-p/454189#M5234</link>
      <description>&lt;P&gt;Add DISPLAY to the DEFINE weightR &amp;nbsp;statement.&lt;/P&gt;
&lt;P&gt;Personally,&amp;nbsp;I also like to explicitly specify the second parameter in the ROUND() function, because it's not the same as the Excel function but people have a tendency to assume it is and it's a common place to make a mistake.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This works for me.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=emp;
    column id salary total weightr ratio;
    define id / display;
    define salary / 'salary';
    define total / 'total';
    define weightr / display 'weight';
    define ratio / computed 'ratio';
    compute ratio;
        ratio=round(weightr/2.2, 0.1);
    endcomp;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/180079"&gt;@smartrambit0&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am new to SAS analytics and running my code on "online sas studio". please let me know what is wrong with the code. I am getting missing value for the computed variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the dataset&lt;/P&gt;
&lt;P&gt;--------------------------&lt;BR /&gt;data emp;&lt;BR /&gt;input id salary total weightr;&lt;BR /&gt;datalines;&lt;BR /&gt;1 2000 5000 20&lt;BR /&gt;2 3000 4000 30&lt;BR /&gt;3 5000 7000 44&lt;BR /&gt;4 2000 4000 55&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the code&lt;/P&gt;
&lt;P&gt;----------------------&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;proc report data=emp;&lt;BR /&gt;column id salary total weightr ratio;&lt;BR /&gt;define id / display;&lt;BR /&gt;define salary / 'salary';&lt;BR /&gt;define total / 'total';&lt;BR /&gt;define weightr / 'weight';&lt;BR /&gt;define ratio / computed 'ratio';&lt;/P&gt;
&lt;P&gt;compute ratio;&lt;BR /&gt;ratio=round(weightr/2.2);&lt;BR /&gt;endcomp;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below is the output&lt;/P&gt;
&lt;P&gt;--------------------------&lt;/P&gt;
&lt;P&gt;id salary total weight ratio&lt;BR /&gt;1 2000 5000 20&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;BR /&gt;2 3000 4000 30&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;BR /&gt;3 5000 7000 44&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;BR /&gt;4 2000 4000 55&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to compute ratio as weight/2.2. Please suggest what is wrong with code here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Apr 2018 18:55:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Not-able-to-compute-a-variable/m-p/454189#M5234</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-04-14T18:55:29Z</dc:date>
    </item>
    <item>
      <title>Re: Not able to compute a variable</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Not-able-to-compute-a-variable/m-p/454193#M5235</link>
      <description>&lt;P&gt;Next code worked for me:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=emp;
    column id salary total weightr ratio;
    define id / order 'ID';
    define salary / 'salary';
    define total / 'total';
    define weightr / order 'weight';
    define ratio / computed format 5.1 'ratio';

    break after weightr / ;
    compute ratio;
        ratio=round(weightr/2.2, 0.3);
    endcomp;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 14 Apr 2018 19:09:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Not-able-to-compute-a-variable/m-p/454193#M5235</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2018-04-14T19:09:01Z</dc:date>
    </item>
    <item>
      <title>Re: Not able to compute a variable</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Not-able-to-compute-a-variable/m-p/454197#M5238</link>
      <description>&lt;P&gt;Perfect thank you. I think, because I did not define it as display variable, SAS treated it as analysis variable as it was numeric datatype.&lt;/P&gt;&lt;P&gt;Due to SAS treating it as analysis variable it was not able to perform mathematical operation on it.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Apr 2018 19:20:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Not-able-to-compute-a-variable/m-p/454197#M5238</guid>
      <dc:creator>smartrambit0</dc:creator>
      <dc:date>2018-04-14T19:20:30Z</dc:date>
    </item>
    <item>
      <title>Re: Not able to compute a variable</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Not-able-to-compute-a-variable/m-p/454201#M5239</link>
      <description>&lt;P&gt;Compute can be done only on GROUP or ORDER variable and there is need to define BREAK statement.&lt;/P&gt;</description>
      <pubDate>Sat, 14 Apr 2018 19:39:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Not-able-to-compute-a-variable/m-p/454201#M5239</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2018-04-14T19:39:25Z</dc:date>
    </item>
  </channel>
</rss>

